summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2015-06-15 15:51:02 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2015-06-15 15:59:49 +0900
commit6e86cd7de3a6ce6d2ef81bcb5a105fc0e6916c56 (patch)
tree79f7d288b76d2949dbf95c8bf48ea75482de2174
parent222b87d41baf19dc61de6febed366a6db2b847f0 (diff)
index: Add NULL check for malloc memory allocation.
-rw-r--r--src/lib/elm_index.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/elm_index.c b/src/lib/elm_index.c
index 3ac9a4626..f07063fb0 100644
--- a/src/lib/elm_index.c
+++ b/src/lib/elm_index.c
@@ -137,7 +137,18 @@ _omit_calc(void *data, int num_of_items, int max_num_of_items)
137 num_of_extra_items = num_of_items - max_num_of_items; 137 num_of_extra_items = num_of_items - max_num_of_items;
138 138
139 group_pos = (int *)malloc(sizeof(int) * max_group_num); 139 group_pos = (int *)malloc(sizeof(int) * max_group_num);
140 if (!group_pos)
141 {
142 ERR("failed to allocate memory!");
143 return;
144 }
140 omit_info = (int *)malloc(sizeof(int) * max_num_of_items); 145 omit_info = (int *)malloc(sizeof(int) * max_num_of_items);
146 if (!omit_info)
147 {
148 ERR("failed to allocate memory!");
149 free(group_pos);
150 return;
151 }
141 152
142 if (num_of_extra_items >= max_group_num) 153 if (num_of_extra_items >= max_group_num)
143 { 154 {
@@ -169,6 +180,11 @@ _omit_calc(void *data, int num_of_items, int max_num_of_items)
169 if (omit_info[i] > 1) 180 if (omit_info[i] > 1)
170 { 181 {
171 o = (Elm_Index_Omit *)malloc(sizeof(Elm_Index_Omit)); 182 o = (Elm_Index_Omit *)malloc(sizeof(Elm_Index_Omit));
183 if (!o)
184 {
185 ERR("failed to allocate memory!");
186 break;
187 }
172 o->offset = sum; 188 o->offset = sum;
173 o->count = omit_info[i]; 189 o->count = omit_info[i];
174 sd->omit = eina_list_append(sd->omit, o); 190 sd->omit = eina_list_append(sd->omit, o);