[Bf-blender-cvs] [a64cb41] master: Trying to pack image with invalid path crashes

Antony Riakiotakis noreply at git.blender.org
Tue May 26 13:46:21 CEST 2015


Commit: a64cb4185e2a6695d7fe12637fd9b624714fe75e
Author: Antony Riakiotakis
Date:   Tue May 26 13:45:45 2015 +0200
Branches: master
https://developer.blender.org/rBa64cb4185e2a6695d7fe12637fd9b624714fe75e

Trying to pack image with invalid path crashes

===================================================================

M	source/blender/blenkernel/intern/image.c

===================================================================

diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 7b6e749..f22a519 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1017,7 +1017,12 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
 		ImagePackedFile *imapf = MEM_mallocN(sizeof(ImagePackedFile), "Image packed file");
 		BLI_addtail(&ima->packedfiles, imapf);
 		imapf->packedfile = newPackedFile(reports, ima->name, basepath);
-		BLI_strncpy(imapf->filepath, ima->name, sizeof(imapf->filepath));
+		if (imapf->packedfile) {
+			BLI_strncpy(imapf->filepath, ima->name, sizeof(imapf->filepath));
+		}
+		else {
+			BLI_freelinkN(&ima->packedfiles, imapf);
+		}
 	}
 	else {
 		ImageView *iv;
@@ -1026,7 +1031,12 @@ void BKE_image_packfiles(ReportList *reports, Image *ima, const char *basepath)
 			BLI_addtail(&ima->packedfiles, imapf);
 
 			imapf->packedfile = newPackedFile(reports, iv->filepath, basepath);
-			BLI_strncpy(imapf->filepath, iv->filepath, sizeof(imapf->filepath));
+			if (imapf->packedfile) {
+				BLI_strncpy(imapf->filepath, iv->filepath, sizeof(imapf->filepath));
+			}
+			else {
+				BLI_freelinkN(&ima->packedfiles, imapf);
+			}
 		}
 	}
 }




More information about the Bf-blender-cvs mailing list