summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-10-22 12:25:37 -0700
committerCedric BAIL <cedric@osg.samsung.com>2015-10-22 12:25:39 -0700
commit71e68dcca6518e313738d276d1ac88a71cb43098 (patch)
treea5ea0062e02500a3080e047112ef2bc04d8f0387 /src/lib/eet
parentccd7c2b014e98d2e5dbbd6aa5a7515de794aae98 (diff)
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.c28
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,
2810 int *len) 2810 int *len)
2811{ 2811{
2812 const char *p; 2812 const char *p;
2813 char *tok = NULL; 2813 char *tok = NULL, *temp;
2814 int in_token = 0; 2814 int in_token = 0;
2815 int in_quote = 0; 2815 int in_quote = 0;
2816 int in_escape = 0; 2816 int in_escape = 0;
2817 int tlen = 0, tsize = 0; 2817 int tlen = 0, tsize = 0;
2818 2818
2819#define TOK_ADD(x) \ 2819#define TOK_ADD(x) \
2820 do { \ 2820 do { \
2821 tlen++; \ 2821 tlen++; \
2822 if (tlen >= tsize) \ 2822 if (tlen >= tsize) \
2823 { \ 2823 { \
2824 tsize += 32; \ 2824 tsize += 32; \
2825 tok = realloc(tok, tsize); \ 2825 temp = tok; \
2826 } \ 2826 tok = realloc(tok, tsize); \
2827 tok[tlen - 1] = x; \ 2827 if (!tok) \
2828 { \
2829 tok = temp; \
2830 ERR("Realloc failed\n"); \
2831 goto realloc_error; \
2832 } \
2833 } \
2834 tok[tlen - 1] = x; \
2828 } while (0) 2835 } while (0)
2829 2836
2830 for (p = src; *len > 0; p++, (*len)--) 2837 for (p = src; *len > 0; p++, (*len)--)
@@ -2890,6 +2897,7 @@ _eet_data_dump_token_get(const char *src,
2890 return tok; 2897 return tok;
2891 } 2898 }
2892 2899
2900realloc_error:
2893 free(tok); 2901 free(tok);
2894 2902
2895 return NULL; 2903 return NULL;