Remove variable length arrays
These are not allowed in C++, and have been made optional in C11.
So let's just get rid of them and any issues they may cause.
diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx
index 1d359d2..e42546d 100644
--- a/common/rfb/CMsgReader.cxx
+++ b/common/rfb/CMsgReader.cxx
@@ -210,7 +210,7 @@
if (width > maxCursorSize || height > maxCursorSize)
throw Exception("Too big cursor");
- rdr::U8 buf[width*height*4];
+ rdr::U8Array rgba(width*height*4);
if (width * height > 0) {
rdr::U8 pr, pg, pb;
@@ -235,7 +235,7 @@
is->readBytes(mask.buf, mask_len);
int maskBytesPerRow = (width+7)/8;
- out = buf;
+ out = rgba.buf;
for (y = 0;y < height;y++) {
for (x = 0;x < width;x++) {
int byte = y * maskBytesPerRow + x / 8;
@@ -261,7 +261,7 @@
}
}
- handler->setCursor(width, height, hotspot, buf);
+ handler->setCursor(width, height, hotspot, rgba.buf);
}
void CMsgReader::readSetCursor(int width, int height, const Point& hotspot)
@@ -275,7 +275,7 @@
rdr::U8Array mask(mask_len);
int x, y;
- rdr::U8 buf[width*height*4];
+ rdr::U8Array rgba(width*height*4);
rdr::U8* in;
rdr::U8* out;
@@ -284,7 +284,7 @@
int maskBytesPerRow = (width+7)/8;
in = data.buf;
- out = buf;
+ out = rgba.buf;
for (y = 0;y < height;y++) {
for (x = 0;x < width;x++) {
int byte = y * maskBytesPerRow + x / 8;
@@ -302,7 +302,7 @@
}
}
- handler->setCursor(width, height, hotspot, buf);
+ handler->setCursor(width, height, hotspot, rgba.buf);
}
void CMsgReader::readSetCursorWithAlpha(int width, int height, const Point& hotspot)