From fd25a6425c7bafff2746b5c349e7313b0110c041 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sat, 19 Oct 2013 22:10:26 +0200 Subject: [PATCH] Fix two memory leaks. --- env_universal_common.cpp | 3 +++ xdgmimemagic.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/env_universal_common.cpp b/env_universal_common.cpp index f600e70a9..e82333a79 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -398,6 +398,9 @@ start_conversion: { debug(0, L"%d %d", in_len, out_len); debug(0, L"Error while converting from to string"); + + /* Terminate the output string. */ + free(out); return 0; } diff --git a/xdgmimemagic.cpp b/xdgmimemagic.cpp index 3f67b2906..8bcca9488 100644 --- a/xdgmimemagic.cpp +++ b/xdgmimemagic.cpp @@ -276,7 +276,10 @@ _xdg_mime_magic_parse_header(FILE *magic_file, XdgMimeMagicMatch *match) buffer = _xdg_mime_magic_read_to_newline(magic_file, &end_of_file); if (end_of_file) + { + free(buffer); return XDG_MIME_MAGIC_EOF; + } end_ptr = buffer; while (*end_ptr != ']' && *end_ptr != '\000' && *end_ptr != '\n')