aboutsummaryrefslogtreecommitdiff
path: root/src/mime.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2020-01-30 09:03:11 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2020-01-30 09:03:11 -0500
commita208097c9091137908beaa1f1f261072df55d3fa (patch)
tree8818bfa6c19c4a43b7bb19431a442d3bdfa9a80e /src/mime.c
parent7c2b1baad8434f9f7b19efe48719942cb3bce4cd (diff)
downloadspmc-a208097c9091137908beaa1f1f261072df55d3fa.tar.gz
SEAD - memory leaks
Diffstat (limited to 'src/mime.c')
-rw-r--r--src/mime.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mime.c b/src/mime.c
index 33bc017..95b5660 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -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;
}