diff options
author | Leandro Pereira <leandro@hardinfo.org> | 2017-07-31 19:53:25 -0700 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2017-08-04 09:23:23 -0700 |
commit | e42e6adf46025eb0ed8ac03c5bac672d52fafb4a (patch) | |
tree | 95bef53f23afd8898fa20147256fba48457aceb4 /modules/computer | |
parent | 3ec07bbb0f6f67215eceb3952efb97032bd4c1a9 (diff) |
Plug memleak when detecting distribution
If the output of `lsb_release -d` didn't contain a "Description: "
substring, it would leak.
Diffstat (limited to 'modules/computer')
-rw-r--r-- | modules/computer/os.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/modules/computer/os.c b/modules/computer/os.c index 806ccce6..6accc0a3 100644 --- a/modules/computer/os.c +++ b/modules/computer/os.c @@ -328,12 +328,10 @@ detect_distro(void) int i; if (g_spawn_command_line_sync("lsb_release -d", &contents, NULL, NULL, NULL)) { - gchar *tmp = strstr(contents, "Description:\t"); + gchar *tmp = strstr(idle_free(contents), "Description:\t"); - if (tmp) { - idle_free(contents); + if (tmp) return g_strdup(tmp + strlen("Description:\t")); - } } for (i = 0; distro_db[i].file; i++) { |