From 706286c28956e51873bfe6b673bea5be01ee7839 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 10 May 2014 16:01:44 +0200 Subject: [PATCH] Fixes use-after-free issue. Calling writer() might fail in which case launch_buff gets freed. This patch prevents the subsequent use of memory after it was freed. --- mimedb.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mimedb.cpp b/mimedb.cpp index 0a4106b24..bbc29227f 100644 --- a/mimedb.cpp +++ b/mimedb.cpp @@ -1190,6 +1190,12 @@ static void launch(char *filter, const string_list_t &files, size_t fileno) writer('&'); writer('\0'); + /* + Calling writer might fail in which case launch_buff gets freed. + */ + if (error) + return; + if (system(launch_buff) == -1) { fprintf(stderr, _(ERROR_SYSTEM), MIMEDB, launch_buff);