diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-01-30 09:03:11 -0500 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-01-30 09:03:11 -0500 |
commit | a208097c9091137908beaa1f1f261072df55d3fa (patch) | |
tree | 8818bfa6c19c4a43b7bb19431a442d3bdfa9a80e /src/mime.c | |
parent | 7c2b1baad8434f9f7b19efe48719942cb3bce4cd (diff) | |
download | spmc-a208097c9091137908beaa1f1f261072df55d3fa.tar.gz |
SEAD - memory leaks
Diffstat (limited to 'src/mime.c')
-rw-r--r-- | src/mime.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -47,14 +47,17 @@ Mime *file_mimetype(const char *filename) { Process *proc = file_command(filename); if (proc->returncode != 0) { + shell_free(proc); return NULL; } output = split(proc->output, ":"); if (!output || output[1] == NULL) { + shell_free(proc); return NULL; } parts = split(output[1], ";"); if (!parts || !parts[0] || !parts[1]) { + shell_free(proc); return NULL; } @@ -65,7 +68,7 @@ Mime *file_mimetype(const char *filename) { charset = lstrip(charset); charset[strlen(charset) - 1] = '\0'; - char *origin = strdup(realpath(filename, NULL)); + char *origin = realpath(filename, NULL); type = (Mime *)calloc(1, sizeof(Mime)); type->origin = origin; @@ -74,6 +77,7 @@ Mime *file_mimetype(const char *filename) { split_free(output); split_free(parts); + shell_free(proc); return type; } |