Fixed memory leak in icon loading

This commit is contained in:
o9000 2016-08-08 10:56:06 +02:00
parent 8b08930268
commit 2857b96c4d
3 changed files with 7 additions and 5 deletions

View file

@ -86,6 +86,8 @@ void load_cache(Cache *cache, const gchar *cache_path)
if (parse_line(line, &key, &value)) { if (parse_line(line, &key, &value)) {
g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value)); g_hash_table_insert(cache->_table, g_strdup(key), g_strdup(value));
free(key);
free(value);
} }
} }
free(line); free(line);

View file

@ -73,15 +73,15 @@ void copy_file(const char *path_src, const char *path_dest)
fclose(file_src); fclose(file_src);
} }
int parse_line(const char *line, char **key, char **value) gboolean parse_line(const char *line, char **key, char **value)
{ {
char *a, *b; char *a, *b;
/* Skip useless lines */ /* Skip useless lines */
if ((line[0] == '#') || (line[0] == '\n')) if ((line[0] == '#') || (line[0] == '\n'))
return 0; return FALSE;
if (!(a = strchr(line, '='))) if (!(a = strchr(line, '=')))
return 0; return FALSE;
/* overwrite '=' with '\0' */ /* overwrite '=' with '\0' */
a[0] = '\0'; a[0] = '\0';
@ -96,7 +96,7 @@ int parse_line(const char *line, char **key, char **value)
g_strstrip(*key); g_strstrip(*key);
g_strstrip(*value); g_strstrip(*value);
return 1; return TRUE;
} }
void tint_exec(const char *command) void tint_exec(const char *command)

View file

@ -48,7 +48,7 @@ void copy_file(const char *path_src, const char *path_dest);
// Strips key and value. // Strips key and value.
// Values may contain spaces and the equal sign. // Values may contain spaces and the equal sign.
// Returns 1 if both key and value could be read, zero otherwise. // Returns 1 if both key and value could be read, zero otherwise.
int parse_line(const char *line, char **key, char **value); gboolean parse_line(const char *line, char **key, char **value);
void extract_values(const char *value, char **value1, char **value2, char **value3); void extract_values(const char *value, char **value1, char **value2, char **value3);