diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-04-14 21:00:27 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-04-15 12:59:11 -0400 |
commit | b557c17a37fc05ae8905d2ab310a1ad0d53834c0 (patch) | |
tree | 60fe38e3c61b46b39a4b48181bc38d5387d19fcd /src/qt/qrcodedialog.cpp | |
parent | 278074eb238446d7feb90dafcbb537baa0068080 (diff) | |
download | bitcoin-b557c17a37fc05ae8905d2ab310a1ad0d53834c0.tar.xz |
Bugfix: Check that QRcode_encodeString didn't return NULL (error)
Without this, any error will segfault Bitcoin-Qt
Diffstat (limited to 'src/qt/qrcodedialog.cpp')
-rw-r--r-- | src/qt/qrcodedialog.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qt/qrcodedialog.cpp b/src/qt/qrcodedialog.cpp index 9cf50b0e58..567cfa75f1 100644 --- a/src/qt/qrcodedialog.cpp +++ b/src/qt/qrcodedialog.cpp @@ -38,12 +38,16 @@ void QRCodeDialog::genCode() { QString uri = getURI(); //qDebug() << "Encoding:" << uri.toUtf8().constData(); - QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); - if (code) + { ui->lblQRCode->setText(""); QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); + if (!code) + { + ui->lblQRCode->setText(tr("Error encoding URI into QR Code.")); + return; + } myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); myImage.fill(0xffffff); unsigned char *p = code->data; @@ -58,8 +62,6 @@ void QRCodeDialog::genCode() QRcode_free(code); ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300)); } - else - ui->lblQRCode->setText(tr("Error encoding URI into QR Code; try to reduce the text for label / message.")); } QString QRCodeDialog::getURI() |