summaryrefslogtreecommitdiff
path: root/src/bin/efreet
diff options
context:
space:
mode:
authorStefan Schmidt <stefan@osg.samsung.com>2017-05-11 09:34:53 +0200
committerStefan Schmidt <stefan@osg.samsung.com>2017-05-11 09:34:53 +0200
commit55676b335c697420fc3760c7125473b6fb250577 (patch)
treee89d63020d9b1f4ab3df94bd3613465ba5bf294e /src/bin/efreet
parent2653fd3fda175d6f2ee5e484af2dd0df265746b7 (diff)
efreet: free the allocated buffer before returning
This fixes the commit 169a08c03a6a7270e185bda85d4ab9afd9063c8e (efreetd: BSD optimizations). Coverity rightly pointed out six different leaks of various buffers on error paths. CID: 1374949 1374950 1374951 1374952 1374953 1374954
Diffstat (limited to 'src/bin/efreet')
-rw-r--r--src/bin/efreet/efreetd_cache.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/bin/efreet/efreetd_cache.c b/src/bin/efreet/efreetd_cache.c
index 58fb520ba3..c347acc95e 100644
--- a/src/bin/efreet/efreetd_cache.c
+++ b/src/bin/efreet/efreetd_cache.c
@@ -196,7 +196,11 @@ subdir_cache_save(void)
196 efreet_cache_home_get(), efreet_hostname_get()); 196 efreet_cache_home_get(), efreet_hostname_get());
197 197
198 tmpfd = eina_file_mkstemp(eina_strbuf_string_get(buf), &tmpstr); 198 tmpfd = eina_file_mkstemp(eina_strbuf_string_get(buf), &tmpstr);
199 if (tmpfd < 0) return; 199 if (tmpfd < 0)
200 {
201 eina_strbuf_free(buf);
202 return;
203 }
200 204
201 eina_strbuf_reset(buf); 205 eina_strbuf_reset(buf);
202 206
@@ -324,10 +328,15 @@ icon_cache_update_cache_cb(void *data EINA_UNUSED)
324 if (icon_cache_exe) 328 if (icon_cache_exe)
325 { 329 {
326 icon_queue = EINA_TRUE; 330 icon_queue = EINA_TRUE;
331 eina_strbuf_free(file);
327 return ECORE_CALLBACK_CANCEL; 332 return ECORE_CALLBACK_CANCEL;
328 } 333 }
329 icon_queue = EINA_FALSE; 334 icon_queue = EINA_FALSE;
330 if ((!icon_flush) && (!icon_exts)) return ECORE_CALLBACK_CANCEL; 335 if ((!icon_flush) && (!icon_exts))
336 {
337 eina_strbuf_free(file);
338 return ECORE_CALLBACK_CANCEL;
339 }
331 340
332 if (icon_change_monitors) eina_hash_free(icon_change_monitors); 341 if (icon_change_monitors) eina_hash_free(icon_change_monitors);
333 if (icon_change_monitors_mon) eina_hash_free(icon_change_monitors_mon); 342 if (icon_change_monitors_mon) eina_hash_free(icon_change_monitors_mon);
@@ -650,7 +659,11 @@ icon_changes_listen(void)
650 if (!buf) return; 659 if (!buf) return;
651 660
652 stack = eina_inarray_new(sizeof(struct stat), 16); 661 stack = eina_inarray_new(sizeof(struct stat), 16);
653 if (!stack) return; 662 if (!stack)
663 {
664 eina_strbuf_free(buf);
665 return;
666 }
654 icon_changes_listen_recursive(stack, efreet_icon_deprecated_user_dir_get(), EINA_TRUE); 667 icon_changes_listen_recursive(stack, efreet_icon_deprecated_user_dir_get(), EINA_TRUE);
655 eina_inarray_flush(stack); 668 eina_inarray_flush(stack);
656 icon_changes_listen_recursive(stack, efreet_icon_user_dir_get(), EINA_TRUE); 669 icon_changes_listen_recursive(stack, efreet_icon_user_dir_get(), EINA_TRUE);
@@ -715,10 +728,10 @@ fill_list(const char *file, Eina_List **l)
715 Eina_File_Line *line = NULL; 728 Eina_File_Line *line = NULL;
716 Eina_Strbuf *buf = eina_strbuf_new(); 729 Eina_Strbuf *buf = eina_strbuf_new();
717 if (!buf) return; 730 if (!buf) return;
718 731
719 eina_strbuf_append_printf(buf, "%s/efreet/%s", efreet_cache_home_get(), file); 732 eina_strbuf_append_printf(buf, "%s/efreet/%s", efreet_cache_home_get(), file);
720 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE); 733 f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
721 if (!f) return; 734 if (!f) goto error_buf;
722 it = eina_file_map_lines(f); 735 it = eina_file_map_lines(f);
723 if (!it) goto error; 736 if (!it) goto error;
724 EINA_ITERATOR_FOREACH(it, line) 737 EINA_ITERATOR_FOREACH(it, line)
@@ -731,8 +744,9 @@ fill_list(const char *file, Eina_List **l)
731 } 744 }
732 eina_iterator_free(it); 745 eina_iterator_free(it);
733error: 746error:
734 eina_strbuf_free(buf);
735 eina_file_close(f); 747 eina_file_close(f);
748error_buf:
749 eina_strbuf_free(buf);
736} 750}
737 751
738static void 752static void
@@ -757,6 +771,10 @@ save_list(const char *file, Eina_List *l)
757 eina_strbuf_append_printf(buf, "%s/efreet/%s", efreet_cache_home_get(), file); 771 eina_strbuf_append_printf(buf, "%s/efreet/%s", efreet_cache_home_get(), file);
758 f = fopen(eina_strbuf_string_get(buf), "wb"); 772 f = fopen(eina_strbuf_string_get(buf), "wb");
759 if (!f) return; 773 if (!f) return;
774 {
775 eina_strbuf_free(buf);
776 return;
777 }
760 EINA_LIST_FOREACH(l, ll, path) 778 EINA_LIST_FOREACH(l, ll, path)
761 fprintf(f, "%s\n", path); 779 fprintf(f, "%s\n", path);
762 fclose(f); 780 fclose(f);