summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeunghun Lee <shiin.lee@samsung.com>2015-06-02 14:36:56 +0900
committerGwanglim Lee <gl77.lee@samsung.com>2015-06-03 05:33:36 -0700
commitea4edc7fdc54afb7ac79b510acb53a05b10bce70 (patch)
treeccfdc7584f9dd139646255ab24f981d01a570083
parentdbc37faa7ca742410281c6678783030b1957f757 (diff)
ecore-buffer: fix memory leak when failed to allocate bo.
first allocate the memory for bo, and then if failed allocation for bo_data, then just free "bo" and returning. Change-Id: I9f4eb8f49731ea253d6fbcfacbb17b6a2e15d718
-rw-r--r--src/lib/ecore_buffer/ecore_buffer.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/ecore_buffer/ecore_buffer.c b/src/lib/ecore_buffer/ecore_buffer.c
index 2c4d29ca6a..2aaaaa9d8b 100644
--- a/src/lib/ecore_buffer/ecore_buffer.c
+++ b/src/lib/ecore_buffer/ecore_buffer.c
@@ -255,14 +255,17 @@ ecore_buffer_new(const char* engine, unsigned int width, unsigned int height, Ec
255 return NULL; 255 return NULL;
256 } 256 }
257 257
258 bo_data = bm->be->buffer_alloc(bm->data, width, height, format, flags);
259 if (!bo_data)
260 return NULL;
261
262 bo = calloc(1, sizeof(Ecore_Buffer)); 258 bo = calloc(1, sizeof(Ecore_Buffer));
263 if (!bo) 259 if (!bo)
264 return NULL; 260 return NULL;
265 261
262 bo_data = bm->be->buffer_alloc(bm->data, width, height, format, flags);
263 if (!bo_data)
264 {
265 free(bo);
266 return NULL;
267 }
268
266 bo->bm = bm; 269 bo->bm = bm;
267 bo->width = width; 270 bo->width = width;
268 bo->height = height; 271 bo->height = height;
@@ -297,15 +300,18 @@ ecore_buffer_new_with_tbm_surface(const char *engine, void *tbm_surface, unsigne
297 return NULL; 300 return NULL;
298 } 301 }
299 302
300 bo_data = bm->be->buffer_alloc_with_tbm_surface(bm->data, tbm_surface,
301 &w, &h, &format, flags);
302 if (!bo_data)
303 return NULL;
304
305 bo = calloc(1, sizeof(Ecore_Buffer)); 303 bo = calloc(1, sizeof(Ecore_Buffer));
306 if (!bo) 304 if (!bo)
307 return NULL; 305 return NULL;
308 306
307 bo_data = bm->be->buffer_alloc_with_tbm_surface(bm->data, tbm_surface,
308 &w, &h, &format, flags);
309 if (!bo_data)
310 {
311 free(bo);
312 return NULL;
313 }
314
309 bo->bm = bm; 315 bo->bm = bm;
310 bo->flags = flags; 316 bo->flags = flags;
311 bo->buffer_data = bo_data; 317 bo->buffer_data = bo_data;
@@ -495,14 +501,17 @@ _ecore_buffer_import(const char* engine, int width, int height, Ecore_Buffer_For
495 return NULL; 501 return NULL;
496 } 502 }
497 503
498 bo_data = bm->be->buffer_import(bm->data, width, height, format, type, export_id, flags);
499 if (!bo_data)
500 return NULL;
501
502 bo = calloc(1, sizeof(Ecore_Buffer)); 504 bo = calloc(1, sizeof(Ecore_Buffer));
503 if (!bo) 505 if (!bo)
504 return NULL; 506 return NULL;
505 507
508 bo_data = bm->be->buffer_import(bm->data, width, height, format, type, export_id, flags);
509 if (!bo_data)
510 {
511 free(bo);
512 return NULL;
513 }
514
506 bo->bm = bm; 515 bo->bm = bm;
507 bo->width = width; 516 bo->width = width;
508 bo->height = height; 517 bo->height = height;