memononen / nanosvg

Simple stupid SVG parser
zlib License
1.71k stars 363 forks source link

Don't free gradient stops #126

Closed SergeySlice closed 6 years ago

SergeySlice commented 6 years ago

Hi, I think this is a mistake leading to crash static void nsvg__deleteGradientData(NSVGgradientData* grad) { NSVGgradientData* next; while (grad != NULL) { next = grad->next; free(grad->stops); free(grad); grad = next; } } the line "free(grad->stops)" is wrong because stops not allocated, the pointer is assigned to array. There is allocation for whole grad grad = (NSVGgradient*)AllocateZeroPool(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1)); We can't free a part of the array.

SergeySlice commented 6 years ago

Sorry, my fault. They are copied by value not by pointer.