summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWooHyun Jung <wh0705.jung@samsung.com>2015-06-13 15:45:36 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2015-06-13 15:45:36 +0900
commit1acd0f4d34d4d2a9b2d6159c4fa7c7ed1413627c (patch)
tree13cec511d093c4551109af5debd25348d6c4d2f5
parenta17116e74a0106515c181eaa931f99fc6fccf0bb (diff)
fileselector: add NULL check for memory allocation
-rw-r--r--src/lib/elc_fileselector.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index 7cb27800a..32d3cffe3 100644
--- a/src/lib/elc_fileselector.c
+++ b/src/lib/elc_fileselector.c
@@ -2055,6 +2055,7 @@ _filter_add(Elm_Fileselector_Data *sd, const char *filter_name)
2055{ 2055{
2056 Elm_Fileselector_Filter *ff; 2056 Elm_Fileselector_Filter *ff;
2057 ff = malloc(sizeof(Elm_Fileselector_Filter)); 2057 ff = malloc(sizeof(Elm_Fileselector_Filter));
2058 if (!ff) return NULL;
2058 2059
2059 ff->filter_name = eina_stringshare_add(filter_name); 2060 ff->filter_name = eina_stringshare_add(filter_name);
2060 ff->sd = sd; 2061 ff->sd = sd;
@@ -2080,6 +2081,8 @@ _elm_fileselector_elm_interface_fileselector_mime_types_filter_append(Eo *obj, E
2080 if (!mime_types) return EINA_FALSE; 2081 if (!mime_types) return EINA_FALSE;
2081 2082
2082 ff = _filter_add(sd, filter_name ? filter_name : mime_types); 2083 ff = _filter_add(sd, filter_name ? filter_name : mime_types);
2084 if (!ff) return EINA_FALSE;
2085
2083 ff->filter_type = ELM_FILESELECTOR_MIME_FILTER; 2086 ff->filter_type = ELM_FILESELECTOR_MIME_FILTER;
2084 2087
2085 ff->filter.mime_types = eina_str_split(mime_types, ",", 0); 2088 ff->filter.mime_types = eina_str_split(mime_types, ",", 0);
@@ -2120,14 +2123,19 @@ EOLIAN static Eina_Bool
2120_elm_fileselector_elm_interface_fileselector_custom_filter_append(Eo *obj, Elm_Fileselector_Data *sd, Elm_Fileselector_Filter_Func func, void *data, const char *filter_name) 2123_elm_fileselector_elm_interface_fileselector_custom_filter_append(Eo *obj, Elm_Fileselector_Data *sd, Elm_Fileselector_Filter_Func func, void *data, const char *filter_name)
2121{ 2124{
2122 Elm_Fileselector_Filter *ff; 2125 Elm_Fileselector_Filter *ff;
2126 Elm_Fileselector_Custom_Filter *custom_filter;
2123 Eina_Bool need_theme = EINA_FALSE; 2127 Eina_Bool need_theme = EINA_FALSE;
2124 2128
2125 if (!func) return EINA_FALSE; 2129 if (!func) return EINA_FALSE;
2126 2130
2131 custom_filter = malloc(sizeof(Elm_Fileselector_Custom_Filter));
2132 if (!custom_filter) return EINA_FALSE;
2133
2127 ff = _filter_add(sd, filter_name ? filter_name : "custom"); 2134 ff = _filter_add(sd, filter_name ? filter_name : "custom");
2128 ff->filter_type = ELM_FILESELECTOR_CUSTOM_FILTER; 2135 if (!ff) return EINA_FALSE;
2129 2136
2130 ff->filter.custom = malloc(sizeof(Elm_Fileselector_Custom_Filter)); 2137 ff->filter_type = ELM_FILESELECTOR_CUSTOM_FILTER;
2138 ff->filter.custom = custom_filter;
2131 ff->filter.custom->func = func; 2139 ff->filter.custom->func = func;
2132 ff->filter.custom->data = data; 2140 ff->filter.custom->data = data;
2133 2141