[Bf-blender-cvs] [a4cd7b7297a] master: Fix potential memory leak in Cycles loading of packed/generated images.

Brecht Van Lommel noreply at git.blender.org
Fri Jul 21 01:08:33 CEST 2017


Commit: a4cd7b7297ad1474c8adf9d5c6aeb52f2397a572
Author: Brecht Van Lommel
Date:   Thu Jul 20 22:31:02 2017 +0200
Branches: master
https://developer.blender.org/rBa4cd7b7297ad1474c8adf9d5c6aeb52f2397a572

Fix potential memory leak in Cycles loading of packed/generated images.

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

M	intern/cycles/blender/blender_session.cpp

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 2b5dd5eadea..753b3822cab 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -1115,7 +1115,6 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name,
 
 	if(image_pixels && num_pixels * channels == pixels_size) {
 		memcpy(pixels, image_pixels, pixels_size * sizeof(unsigned char));
-		MEM_freeN(image_pixels);
 	}
 	else {
 		if(channels == 1) {
@@ -1134,6 +1133,11 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name,
 			}
 		}
 	}
+
+	if(image_pixels) {
+		MEM_freeN(image_pixels);
+	}
+
 	/* Premultiply, byte images are always straight for Blender. */
 	unsigned char *cp = pixels;
 	for(size_t i = 0; i < num_pixels; i++, cp += channels) {
@@ -1172,7 +1176,6 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
 
 		if(image_pixels && num_pixels * channels == pixels_size) {
 			memcpy(pixels, image_pixels, pixels_size * sizeof(float));
-			MEM_freeN(image_pixels);
 		}
 		else {
 			if(channels == 1) {
@@ -1192,6 +1195,10 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
 			}
 		}
 
+		if(image_pixels) {
+			MEM_freeN(image_pixels);
+		}
+
 		return true;
 	}
 	else if(b_id.is_a(&RNA_Object)) {




More information about the Bf-blender-cvs mailing list