Skip to content

Commit 5bcff0e

Browse files
committed
exec.c: Fix "use after free" in 'bd_utils_check_util_version'
1 parent e97de48 commit 5bcff0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/exec.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,18 +670,20 @@ gboolean bd_utils_check_util_version (const gchar *util, const gchar *version, c
670670

671671
version_str = g_match_info_fetch (match_info, 1);
672672
g_match_info_free (match_info);
673-
g_free (output);
674673
}
675674
else
676-
version_str = g_strstrip (output);
675+
version_str = g_strstrip (g_strdup (output));
677676

678677
if (!version_str || (g_strcmp0 (version_str, "") == 0)) {
679678
g_set_error (error, BD_UTILS_EXEC_ERROR, BD_UTILS_EXEC_ERROR_UTIL_UNKNOWN_VER,
680679
"Failed to determine %s's version from: %s", util, output);
681680
g_free (version_str);
681+
g_free (output);
682682
return FALSE;
683683
}
684684

685+
g_free (output);
686+
685687
if (bd_utils_version_cmp (version_str, version, error) < 0) {
686688
/* smaller version or error */
687689
if (!(*error))

0 commit comments

Comments
 (0)