Fix segfaults when processing very large files in queue, #5170

This commit is contained in:
heckflosse 2019-02-13 00:38:11 +01:00
parent 2d167d923b
commit 8eba1c40a6
3 changed files with 13 additions and 14 deletions

View File

@ -215,7 +215,7 @@ class PlanarWhateverData : virtual public ImageDatas
private:
AlignedBuffer<T> abData;
int rowstride; // Plan size, in bytes (all padding bytes included)
size_t rowstride; // Plan size, in bytes (all padding bytes included)
public:
T* data;
@ -228,7 +228,7 @@ public:
}
// Send back the row stride. WARNING: unit = byte, not element!
int getRowStride () const
size_t getRowStride () const
{
return rowstride;
}
@ -259,7 +259,6 @@ public:
* Can be safely used to reallocate an existing image */
void allocate (int W, int H) override
{
if (W == width && H == height) {
return;
}
@ -591,8 +590,8 @@ class PlanarRGBData : virtual public ImageDatas
private:
AlignedBuffer<T> abData;
int rowstride; // Plan size, in bytes (all padding bytes included)
int planestride; // Row length, in bytes (padding bytes included)
size_t rowstride; // Plan size, in bytes (all padding bytes included)
size_t planestride; // Row length, in bytes (padding bytes included)
protected:
T* data;
@ -602,18 +601,18 @@ public:
PlanarPtr<T> b;
PlanarRGBData() : rowstride(0), planestride(0), data (nullptr) {}
PlanarRGBData(int w, int h) : rowstride(0), planestride(0), data (nullptr)
PlanarRGBData(size_t w, size_t h) : rowstride(0), planestride(0), data (nullptr)
{
allocate(w, h);
}
// Send back the row stride. WARNING: unit = byte, not element!
int getRowStride () const
size_t getRowStride () const
{
return rowstride;
}
// Send back the plane stride. WARNING: unit = byte, not element!
int getPlaneStride () const
size_t getPlaneStride () const
{
return planestride;
}
@ -710,7 +709,7 @@ public:
char *bluestart = (char*)(data) + 2 * planestride;
for (int i = 0; i < height; ++i) {
int k = i * rowstride;
size_t k = i * rowstride;
r(i) = (T*)(redstart + k);
g(i) = (T*)(greenstart + k);
b(i) = (T*)(bluestart + k);

View File

@ -64,7 +64,7 @@ void LabImage::getPipetteData (float &v1, float &v2, float &v3, int posX, int po
v3 = n ? accumulator_b / float(n) : 0.f;
}
void LabImage::allocLab(int w, int h)
void LabImage::allocLab(size_t w, size_t h)
{
L = new float*[h];
a = new float*[h];
@ -73,19 +73,19 @@ void LabImage::allocLab(int w, int h)
data = new float [w * h * 3];
float * index = data;
for (int i = 0; i < h; i++) {
for (size_t i = 0; i < h; i++) {
L[i] = index + i * w;
}
index += w * h;
for (int i = 0; i < h; i++) {
for (size_t i = 0; i < h; i++) {
a[i] = index + i * w;
}
index += w * h;
for (int i = 0; i < h; i++) {
for (size_t i = 0; i < h; i++) {
b[i] = index + i * w;
}
}

View File

@ -25,7 +25,7 @@ namespace rtengine
class LabImage
{
private:
void allocLab(int w, int h);
void allocLab(size_t w, size_t h);
public:
int W, H;