aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/edje
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-08-01 19:51:03 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-08-01 20:03:20 +0900
commitae443173ec2a7941200943c09fa7dbddc2e605e1 (patch)
tree09669d2f8a6c2b0869495e770b86d3e69fa8acd2 /src/bin/edje
parentRevert "elm gesture layer - use fabs not abs when actually comparing floats" (diff)
downloadefl-ae443173ec2a7941200943c09fa7dbddc2e605e1.tar.gz
edje_svg: Fix handling of realloc
This amends 8e311db414950e399099acc1c0a as the logic was badly broken. A "shadow" variable warning clearly showed that "tmp" was not used properly. This fixes the "IBM" logo in svg-test (the only one using polygon/polyline, it seems).
Diffstat (limited to 'src/bin/edje')
-rw-r--r--src/bin/edje/edje_svg_loader.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/bin/edje/edje_svg_loader.c b/src/bin/edje/edje_svg_loader.c
index 65e17f1094..03088ca638 100644
--- a/src/bin/edje/edje_svg_loader.c
+++ b/src/bin/edje/edje_svg_loader.c
@@ -1106,22 +1106,16 @@ _attr_parse_polygon_points(const char *str, double **points, int *point_count)
int tmp_count=0;
int count = 0;
double num;
- double *point_array = NULL;
+ double *point_array = NULL, *tmp_array;
while (_parse_number(&str, &num))
{
tmp[tmp_count++] = num;
if (tmp_count == 50)
{
- double *tmp;
-
- tmp = realloc(point_array, (count + tmp_count) * sizeof(double));
- if (!tmp)
- {
- ERR("allocation for point array failed. out of memory");
- abort();
- }
- point_array = tmp;
+ tmp_array = realloc(point_array, (count + tmp_count) * sizeof(double));
+ if (!tmp_array) goto error_alloc;
+ point_array = tmp_array;
memcpy(&point_array[count], tmp, tmp_count * sizeof(double));
count += tmp_count;
tmp_count = 0;
@@ -1130,20 +1124,19 @@ _attr_parse_polygon_points(const char *str, double **points, int *point_count)
if (tmp_count > 0)
{
- double *tmp;
-
- tmp = realloc(point_array, (count + tmp_count) * sizeof(double));
- if (!tmp)
- {
- ERR("allocation for point array failed. out of memory");
- abort();
- }
- point_array = tmp;
+ tmp_array = realloc(point_array, (count + tmp_count) * sizeof(double));
+ if (!tmp_array) goto error_alloc;
+ point_array = tmp_array;
memcpy(&point_array[count], tmp, tmp_count * sizeof(double));
count += tmp_count;
}
*point_count = count;
*points = point_array;
+ return;
+
+error_alloc:
+ ERR("allocation for point array failed. out of memory");
+ abort();
}
/* parse the attributes for a polygon element.