- #4183, St_AsMVTGeom: Drop invalid geometries after simplification (Raúl Marín)
- #4188, Avoid division by zero in kmeans (Raúl Marín)
- #4189, Fix undefined behaviour in SADFWrite (Raúl Marín)
+ - #4191, Fix undefined behaviour in ptarray_clone_deep (Raúl Marín)
PostGIS 2.5.0
2018/09/23
ptarray_clone_deep(const POINTARRAY *in)
{
POINTARRAY *out = lwalloc(sizeof(POINTARRAY));
- size_t size;
LWDEBUG(3, "ptarray_clone_deep called.");
FLAGS_SET_READONLY(out->flags, 0);
- size = in->npoints * ptarray_point_size(in);
- out->serialized_pointlist = lwalloc(size);
- memcpy(out->serialized_pointlist, in->serialized_pointlist, size);
+ if (!in->npoints)
+ {
+ // Avoid calling lwalloc of 0 bytes
+ out->serialized_pointlist = NULL;
+ }
+ else
+ {
+ size_t size = in->npoints * ptarray_point_size(in);
+ out->serialized_pointlist = lwalloc(size);
+ memcpy(out->serialized_pointlist, in->serialized_pointlist, size);
+ }
return out;
}