summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-24 13:37:57 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-24 13:37:57 +0900
commit878644970481e0ca14065f0391a87df2ef3d80f8 (patch)
tree524c4bd7f53ce3f10a251db6e8f7c2b54d4307fb
parent8e311db414950e399099acc1c0af620ee2f37b52 (diff)
downloadefl-878644970481e0ca14065f0391a87df2ef3d80f8.tar.gz
efreetd cache create - fix reallocs to bail on out of memory cleanly
-rw-r--r--src/bin/efreet/efreet_icon_cache_create.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/bin/efreet/efreet_icon_cache_create.c b/src/bin/efreet/efreet_icon_cache_create.c
index 9cefc82dad..6fc709ff23 100644
--- a/src/bin/efreet/efreet_icon_cache_create.c
+++ b/src/bin/efreet/efreet_icon_cache_create.c
@@ -237,6 +237,7 @@ cache_scan_path_dir(Efreet_Icon_Theme *theme,
Efreet_Cache_Icon *icon;
char *name;
char *ext;
+ const char **tmp;
unsigned int i;
if (entry->type == EINA_FILE_DIR)
@@ -309,8 +310,16 @@ cache_scan_path_dir(Efreet_Icon_Theme *theme,
*/
else if (!strcmp(icon->theme, theme->name.internal))
{
- icon->icons = realloc(icon->icons,
- sizeof (Efreet_Cache_Icon_Element*) * (++icon->icons_count));
+ Efreet_Cache_Icon_Element **tmp2;
+
+ tmp2 = realloc(icon->icons,
+ sizeof(Efreet_Cache_Icon_Element *) * (++icon->icons_count));
+ if (!tmp2)
+ {
+ ERR("Out of memory");
+ exit(1);
+ }
+ icon->icons = tmp2;
icon->icons[i] = NEW(Efreet_Cache_Icon_Element, 1);
icon->icons[i]->type = dir->type;
icon->icons[i]->normal = dir->size.normal;
@@ -325,8 +334,14 @@ cache_scan_path_dir(Efreet_Icon_Theme *theme,
}
/* and finally store the path */
- icon->icons[i]->paths = realloc(icon->icons[i]->paths,
- sizeof (char*) * (icon->icons[i]->paths_count + 1));
+ tmp = realloc(icon->icons[i]->paths,
+ sizeof(char *) * (icon->icons[i]->paths_count + 1));
+ if (!tmp)
+ {
+ ERR("Out of memory");
+ exit(1);
+ }
+ icon->icons[i]->paths = tmp;
icon->icons[i]->paths[icon->icons[i]->paths_count] = eina_stringshare_add(entry->path);
eina_array_push(strs, icon->icons[i]->paths[icon->icons[i]->paths_count++]);
}