Potentially breaking change, free old strings

This commit is contained in:
ArsenArsen 2017-12-08 00:30:30 +01:00
parent bd966ba2e6
commit 8a24646c49
No known key found for this signature in database
GPG key ID: 683D2F43B0CA4BD2

16
rsudo.c
View file

@ -40,13 +40,14 @@ struct header_s {
int op; int op;
}; };
char *join(const char *s1, const char *s2) { char *join(char *s1, char *s2) {
free((void *)s1);
char *result = malloc(strlen(s1) + strlen(s2) + 1); char *result = malloc(strlen(s1) + strlen(s2) + 1);
if (result) { if (result) {
strcpy(result, s1); strcpy(result, s1);
strcat(result, s2); strcat(result, s2);
} }
free(s1);
free(s2);
return result; return result;
} }
@ -110,17 +111,6 @@ int main(int argc, char **argv) {
exit(-1); exit(-1);
} }
/*
if(strlen(buffer) != header.len || strlen(buffer) - 1 != header.len)
{
printf("%u %d\n", strlen(buffer), header.len);
LOG_ERROR("main", "hello length != header length");
exit(-1);
}
*/
if (header.op != 0) { if (header.op != 0) {
LOG_ERROR("main", "incorrect header op"); LOG_ERROR("main", "incorrect header op");
exit(-1); exit(-1);