Fix T97150: Export GPencil to PDF or SVG crashes blender

The problem was the original file had some vertex  weight information, but the weights array was empty, so the duplication was not done and the free memory crashed.

To avoid this type of errors, now before duplicate weights the function checks the pointer and also the number of weights elements in the array to avoid the duplicatiopn of empty data.
This commit is contained in:
Antonio Vazquez 2022-04-08 12:18:15 +02:00
parent aa46a67634
commit aa1e8bb9ab
Notes: blender-bot 2023-02-14 11:20:29 +01:00
Referenced by issue #98488, Regression: Grease Pencil weightpaint not visible until the very first point has been painted on
Referenced by issue #97150, Export GP to PDF or SVG crashes blender
1 changed files with 1 additions and 1 deletions

View File

@ -867,7 +867,7 @@ bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src,
if (dup_points) {
gps_dst->points = MEM_dupallocN(gps_src->points);
if (gps_src->dvert != NULL) {
if ((gps_src->dvert != NULL) && (gps_src->dvert->totweight > 0)) {
gps_dst->dvert = MEM_dupallocN(gps_src->dvert);
BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
}