Close #2964: Fix Segmentation fault in rtengine::processImage due to crop

When a pp3 contains negative values for X & Y in the Crop section these get
parsed into array indexing code without being checked and set to 0. This results
in a segmentation fault because the code tries to index the '-1' element of the
array.
This commit is contained in:
Harshula Jayasuriya
2015-12-20 13:26:27 +01:00
committed by Adam Reichold
parent 7227ccc63c
commit 13e7260a23

View File

@@ -77,6 +77,14 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
params.crop.w = fw; params.crop.w = fw;
params.crop.h = fh; params.crop.h = fh;
} else { } else {
if (params.crop.x < 0) {
params.crop.x = 0;
}
if (params.crop.y < 0) {
params.crop.y = 0;
}
if ((params.crop.x + params.crop.w) > fw) { if ((params.crop.x + params.crop.w) > fw) {
// crop overflow in the width dimension ; we trim it // crop overflow in the width dimension ; we trim it
params.crop.w = fw - params.crop.x; params.crop.w = fw - params.crop.x;