Fix: Mantaflow: move allocation after early return
Varibale `pic` is allowcated before an early return, which could cause a memory leak. Now fixed. Pull Request: https://projects.blender.org/blender/blender/pulls/121104
This commit is contained in:
parent
cb93603fb3
commit
71e7775bcb
4
extern/mantaflow/helper/util/simpleimage.cpp
vendored
4
extern/mantaflow/helper/util/simpleimage.cpp
vendored
@ -152,8 +152,6 @@ bool SimpleImage::initFromPpm(std::string filename)
|
|||||||
rowsize = windW * 3;
|
rowsize = windW * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *pic = new unsigned char[size]; // (GLubyte *)malloc (size);
|
|
||||||
|
|
||||||
// Read in maximum value (ignore) , could be scanned with sscanf as well, but this should be
|
// Read in maximum value (ignore) , could be scanned with sscanf as well, but this should be
|
||||||
// 255... 3rd line
|
// 255... 3rd line
|
||||||
if (fgets(line, MAXLINE, fp) == nullptr) {
|
if (fgets(line, MAXLINE, fp) == nullptr) {
|
||||||
@ -162,6 +160,8 @@ bool SimpleImage::initFromPpm(std::string filename)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char *pic = new unsigned char[size]; // (GLubyte *)malloc (size);
|
||||||
|
|
||||||
// Read in the pixel array row-by-row: 1st row = top scanline */
|
// Read in the pixel array row-by-row: 1st row = top scanline */
|
||||||
unsigned char *ptr = nullptr;
|
unsigned char *ptr = nullptr;
|
||||||
ptr = &pic[(windH - 1) * rowsize];
|
ptr = &pic[(windH - 1) * rowsize];
|
||||||
|
Loading…
Reference in New Issue
Block a user