Potentially breaking change, free old strings
This commit is contained in:
parent
bd966ba2e6
commit
8a24646c49
1 changed files with 3 additions and 13 deletions
16
rsudo.c
16
rsudo.c
|
@ -40,13 +40,14 @@ struct header_s {
|
|||
int op;
|
||||
};
|
||||
|
||||
char *join(const char *s1, const char *s2) {
|
||||
free((void *)s1);
|
||||
char *join(char *s1, char *s2) {
|
||||
char *result = malloc(strlen(s1) + strlen(s2) + 1);
|
||||
if (result) {
|
||||
strcpy(result, s1);
|
||||
strcat(result, s2);
|
||||
}
|
||||
free(s1);
|
||||
free(s2);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -110,17 +111,6 @@ int main(int argc, char **argv) {
|
|||
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) {
|
||||
LOG_ERROR("main", "incorrect header op");
|
||||
exit(-1);
|
||||
|
|
Loading…
Reference in a new issue