diff options
author | Srivardhan Hebbar <sri.hebbar@samsung.com> | 2015-10-22 12:25:37 -0700 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-10-22 12:25:39 -0700 |
commit | 71e68dcca6518e313738d276d1ac88a71cb43098 (patch) | |
tree | a5ea0062e02500a3080e047112ef2bc04d8f0387 /src/lib/eet | |
parent | ccd7c2b014e98d2e5dbbd6aa5a7515de794aae98 (diff) | |
download | efl-71e68dcca6518e313738d276d1ac88a71cb43098.tar.gz |
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>
Diffstat (limited to 'src/lib/eet')
-rw-r--r-- | src/lib/eet/eet_data.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/lib/eet/eet_data.c b/src/lib/eet/eet_data.c index f2ad492982..a0c5864d3a 100644 --- a/src/lib/eet/eet_data.c +++ b/src/lib/eet/eet_data.c @@ -2810,21 +2810,28 @@ _eet_data_dump_token_get(const char *src, int *len) { const char *p; - char *tok = NULL; + char *tok = NULL, *temp; int in_token = 0; int in_quote = 0; int in_escape = 0; int tlen = 0, tsize = 0; -#define TOK_ADD(x) \ - do { \ - tlen++; \ - if (tlen >= tsize) \ - { \ - tsize += 32; \ - tok = realloc(tok, tsize); \ - } \ - tok[tlen - 1] = x; \ +#define TOK_ADD(x) \ + do { \ + tlen++; \ + if (tlen >= tsize) \ + { \ + tsize += 32; \ + temp = tok; \ + tok = realloc(tok, tsize); \ + if (!tok) \ + { \ + tok = temp; \ + ERR("Realloc failed\n"); \ + goto realloc_error; \ + } \ + } \ + tok[tlen - 1] = x; \ } while (0) for (p = src; *len > 0; p++, (*len)--) @@ -2890,6 +2897,7 @@ _eet_data_dump_token_get(const char *src, return tok; } +realloc_error: free(tok); return NULL; |