[gnome-desktop] gnome-language: Fix potential crash due to freeing unallocated memory
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] gnome-language: Fix potential crash due to freeing unallocated memory
- Date: Mon, 13 Aug 2018 03:09:07 +0000 (UTC)
commit d8ebb9a8a64797db0824edb4a6bbf616a97d14d4
Author: Robert Ancell <robert ancell canonical com>
Date: Mon Aug 13 14:54:51 2018 +1200
gnome-language: Fix potential crash due to freeing unallocated memory
g_autofree support was added in commit 389a3761c, but in this case
if is_utf8 was NULL then this would free memory that wasn't allocated.
Note that the current code always has is_utf8 non-NULL, but this could
break future code.
libgnome-desktop/gnome-languages.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/libgnome-desktop/gnome-languages.c b/libgnome-desktop/gnome-languages.c
index f6756baf..7f95bb43 100644
--- a/libgnome-desktop/gnome-languages.c
+++ b/libgnome-desktop/gnome-languages.c
@@ -305,7 +305,7 @@ language_name_get_codeset_details (const char *language_name,
gboolean *is_utf8)
{
g_autofree char *old_locale = NULL;
- g_autofree char *codeset = NULL;
+ const char *codeset = NULL;
old_locale = g_strdup (setlocale (LC_CTYPE, NULL));
@@ -319,9 +319,9 @@ language_name_get_codeset_details (const char *language_name,
}
if (is_utf8 != NULL) {
- codeset = normalize_codeset (codeset);
+ g_autofree char *normalized_codeset = normalize_codeset (codeset);
- *is_utf8 = strcmp (codeset, "UTF-8") == 0;
+ *is_utf8 = strcmp (normalized_codeset, "UTF-8") == 0;
}
setlocale (LC_CTYPE, old_locale);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]