eet: handling memory leak on realloc fail.

Summary: Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>

Reviewers: cedric

Differential Revision: https://phab.enlightenment.org/D3208

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Srivardhan Hebbar 2015-10-22 12:25:37 -07:00 committed by Cedric BAIL
parent ccd7c2b014
commit 71e68dcca6
1 changed files with 18 additions and 10 deletions

View File

@ -2810,7 +2810,7 @@ _eet_data_dump_token_get(const char *src,
int *len) int *len)
{ {
const char *p; const char *p;
char *tok = NULL; char *tok = NULL, *temp;
int in_token = 0; int in_token = 0;
int in_quote = 0; int in_quote = 0;
int in_escape = 0; int in_escape = 0;
@ -2822,7 +2822,14 @@ _eet_data_dump_token_get(const char *src,
if (tlen >= tsize) \ if (tlen >= tsize) \
{ \ { \
tsize += 32; \ tsize += 32; \
temp = tok; \
tok = realloc(tok, tsize); \ tok = realloc(tok, tsize); \
if (!tok) \
{ \
tok = temp; \
ERR("Realloc failed\n"); \
goto realloc_error; \
} \
} \ } \
tok[tlen - 1] = x; \ tok[tlen - 1] = x; \
} while (0) } while (0)
@ -2890,6 +2897,7 @@ _eet_data_dump_token_get(const char *src,
return tok; return tok;
} }
realloc_error:
free(tok); free(tok);
return NULL; return NULL;