tmp[tmp_count++] = num;
if (tmp_count == 50)
{
- point_array = realloc(point_array, (count + tmp_count) * sizeof(double));
+ 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;
memcpy(&point_array[count], tmp, tmp_count * sizeof(double));
count += tmp_count;
tmp_count = 0;
if (tmp_count > 0)
{
- point_array = realloc(point_array, (count + tmp_count) * sizeof(double));
+ 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;
memcpy(&point_array[count], tmp, tmp_count * sizeof(double));
count += tmp_count;
}