summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index 5e2157e..58093aa 100644
--- a/src/plugins/imageformats/gif/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
@@ -132,8 +132,8 @@ private:
int code_size, clear_code, end_code, max_code_size, max_code;
int firstcode, oldcode, incode;
- short table[2][1<< max_lzw_bits];
- short stack[(1<<(max_lzw_bits))*2];
+ short* table[2];
+ short* stack;
short *sp;
bool needfirst;
int x, y;
@@ -162,6 +162,9 @@ QGIFFormat::QGIFFormat()
lcmap = false;
newFrame = false;
partialNewFrame = false;
+ table[0] = 0;
+ table[1] = 0;
+ stack = 0;
}
/*!
@@ -171,6 +174,7 @@ QGIFFormat::~QGIFFormat()
{
if (globalcmap) delete[] globalcmap;
if (localcmap) delete[] localcmap;
+ delete [] stack;
}
void QGIFFormat::disposePrevious(QImage *image)
@@ -237,6 +241,12 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
// CompuServe Incorporated. GIF(sm) is a Service Mark property of
// CompuServe Incorporated."
+ if (!stack) {
+ stack = new short[(1 << max_lzw_bits) * 4];
+ table[0] = &stack[(1 << max_lzw_bits) * 2];
+ table[1] = &stack[(1 << max_lzw_bits) * 3];
+ }
+
image->detach();
int bpl = image->bytesPerLine();
unsigned char *bits = image->bits();