From 61a58eeba92c5e6e2366ca434e1d055faa8ab9bc Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 15 Sep 2014 23:19:51 +0200 Subject: [PATCH] OP-1493 Fix stack overflow problem when the firmware code size is large --- ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp b/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp index 64bf57be8..d090fc0ed 100644 --- a/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/op_dfu.cpp @@ -1003,7 +1003,7 @@ quint32 DFUObject::CRCFromQBArray(QByteArray array, quint32 Size) quint32 pad = Size - array.length(); array.append(QByteArray(pad, 255)); - quint32 t[Size / 4]; + quint32 *t = new quint32[Size / 4]; for (int x = 0; x < array.length() / 4; x++) { quint32 aux = 0; aux = (char)array[x * 4 + 3] & 0xFF; @@ -1015,7 +1015,11 @@ quint32 DFUObject::CRCFromQBArray(QByteArray array, quint32 Size) aux += (char)array[x * 4 + 0] & 0xFF; t[x] = aux; } - return DFUObject::CRC32WideFast(0xFFFFFFFF, Size / 4, (quint32 *)t); + quint32 ret = DFUObject::CRC32WideFast(0xFFFFFFFF, Size / 4, t); + + delete[] t; + + return ret; }