mirror of https://github.com/status-im/qzxing.git
Free allocated memory before throwing exceptions
This commit is contained in:
parent
74046dac7d
commit
30c599079a
|
@ -404,6 +404,7 @@ void DecodedBitStreamParser::decodeBase256Segment(Ref<BitSource> bits, ostringst
|
|||
// Have seen this particular error in the wild, such as at
|
||||
// http://www.bcgen.com/demo/IDAutomationStreamingDataMatrix.aspx?MODE=3&D=Fred&PFMT=3&PT=F&X=0.3&O=0&LM=0.2
|
||||
if (bits->available() < 8) {
|
||||
delete [] bytes;
|
||||
throw FormatException("byteSegments");
|
||||
}
|
||||
bytes[i] = unrandomize255State(bits->readBits(8), codewordPosition++);
|
||||
|
|
|
@ -229,6 +229,7 @@ void DecodedBitStreamParser::decodeNumericSegment(Ref<BitSource> bits, std::stri
|
|||
while (count >= 3) {
|
||||
// Each 10 bits encodes three digits
|
||||
if (bits->available() < 10) {
|
||||
delete[] bytes;
|
||||
throw ReaderException("format exception");
|
||||
}
|
||||
int threeDigitsBits = bits->readBits(10);
|
||||
|
|
|
@ -416,6 +416,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits,
|
|||
message += " and ";
|
||||
message += zxing::common::StringUtils::intToStr(result->getSizeInBytes());
|
||||
message += " differ.";
|
||||
delete result;
|
||||
throw WriterException(message.c_str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue