glassechidna / zxing-cpp

ZXing C++ Library
Apache License 2.0
598 stars 435 forks source link

GenericGF::inverse(int) BAD_ACCESS crash #14

Open TimZaman opened 9 years ago

TimZaman commented 9 years ago

And another one-in-a-million crash.

Crashed Thread:        179  QThread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00007fa351185688

VM Regions Near 0x7fa351185688:
    MALLOC_NANO            0000658000000000-0000658000600000 [ 6144K] rw-/rwx SM=PRV  
--> 
    MALLOC_TINY            00007fa3b9c00000-00007fa3ba000000 [ 4096K] rw-/rwx SM=PRV  

Thread 179 Crashed:: QThread
0   com.test            0x00000001089aeaa2 zxing::GenericGF::inverse(int) + 210
1   com.test            0x00000001089b2447 zxing::ReedSolomonDecoder::runEuclideanAlgorithm(zxing::Ref<zxing::GenericGFPoly>, zxing::Ref<zxing::GenericGFPoly>, int) + 967
2   com.test            0x00000001089b1a50 zxing::ReedSolomonDecoder::decode(zxing::ArrayRef<int>, int) + 992
3   com.test            0x00000001089bebb2 zxing::datamatrix::Decoder::correctErrors(zxing::ArrayRef<char>, int) + 242
4   com.test            0x00000001089bf0da zxing::datamatrix::Decoder::decode(zxing::Ref<zxing::BitMatrix>) + 954
5   com.test            0x00000001089b632f zxing::datamatrix::DataMatrixReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 239
6   com.test            0x00000001089d858a zxing::MultiFormatReader::decodeInternal(zxing::Ref<zxing::BinaryBitmap>) + 250
7   com.test            0x00000001089d8716 zxing::MultiFormatReader::decode(zxing::Ref<zxing::BinaryBitmap>, zxing::DecodeHints) + 118

comes from GenericGF.cpp

int GenericGF::inverse(int a) {
  checkInit();
  if (a == 0) {
    throw IllegalArgumentException("Cannot calculate the inverse of 0");
  }
  return expTable[size - logTable[a] - 1];
}