more memory leak fixes

This commit is contained in:
swirl 2021-09-30 12:56:08 -04:00
parent 4c87e10c0d
commit 268a172231
1 changed files with 5 additions and 2 deletions

7
main.c
View File

@ -140,7 +140,8 @@ void handle_post(struct mg_connection *nc, struct mg_str content, char *host, ch
char *file = get_file_filename_shortid(shortid, filename);
if (!mg_file_write(file, ucont, content.len)) {
fprintf(stderr, "failed to write to file %s", file);
return mg_http_reply(nc, 500, "", "failed to write data");
mg_http_reply(nc, 500, "", "failed to write data");
return free(shortid);
}
free(file);
@ -148,7 +149,9 @@ void handle_post(struct mg_connection *nc, struct mg_str content, char *host, ch
char *del_file = get_del_filename_shortid(shortid, filename);
if (!mg_file_write(del_file, del_key, strlen(del_key))) {
fprintf(stderr, "failed to write to file %s", del_file);
return mg_http_reply(nc, 500, "", "failed to write data");
mg_http_reply(nc, 500, "", "failed to write data");
free(shortid);
return free(del_file);
}
free(del_file);