summaryrefslogtreecommitdiff
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
parent3b8c60954e2b64aa87810f083b1ae3fda473a7cb (diff)
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).
-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)
1106 int tmp_count=0; 1106 int tmp_count=0;
1107 int count = 0; 1107 int count = 0;
1108 double num; 1108 double num;
1109 double *point_array = NULL; 1109 double *point_array = NULL, *tmp_array;
1110 1110
1111 while (_parse_number(&str, &num)) 1111 while (_parse_number(&str, &num))
1112 { 1112 {
1113 tmp[tmp_count++] = num; 1113 tmp[tmp_count++] = num;
1114 if (tmp_count == 50) 1114 if (tmp_count == 50)
1115 { 1115 {
1116 double *tmp; 1116 tmp_array = realloc(point_array, (count + tmp_count) * sizeof(double));
1117 1117 if (!tmp_array) goto error_alloc;
1118 tmp = realloc(point_array, (count + tmp_count) * sizeof(double)); 1118 point_array = tmp_array;
1119 if (!tmp)
1120 {
1121 ERR("allocation for point array failed. out of memory");
1122 abort();
1123 }
1124 point_array = tmp;
1125 memcpy(&point_array[count], tmp, tmp_count * sizeof(double)); 1119 memcpy(&point_array[count], tmp, tmp_count * sizeof(double));
1126 count += tmp_count; 1120 count += tmp_count;
1127 tmp_count = 0; 1121 tmp_count = 0;
@@ -1130,20 +1124,19 @@ _attr_parse_polygon_points(const char *str, double **points, int *point_count)
1130 1124
1131 if (tmp_count > 0) 1125 if (tmp_count > 0)
1132 { 1126 {
1133 double *tmp; 1127 tmp_array = realloc(point_array, (count + tmp_count) * sizeof(double));
1134 1128 if (!tmp_array) goto error_alloc;
1135 tmp = realloc(point_array, (count + tmp_count) * sizeof(double)); 1129 point_array = tmp_array;
1136 if (!tmp)
1137 {
1138 ERR("allocation for point array failed. out of memory");
1139 abort();
1140 }
1141 point_array = tmp;
1142 memcpy(&point_array[count], tmp, tmp_count * sizeof(double)); 1130 memcpy(&point_array[count], tmp, tmp_count * sizeof(double));
1143 count += tmp_count; 1131 count += tmp_count;
1144 } 1132 }
1145 *point_count = count; 1133 *point_count = count;
1146 *points = point_array; 1134 *points = point_array;
1135 return;
1136
1137error_alloc:
1138 ERR("allocation for point array failed. out of memory");
1139 abort();
1147} 1140}
1148 1141
1149/* parse the attributes for a polygon element. 1142/* parse the attributes for a polygon element.