Mercurial > hg > bitcoin
changeset 2886:ae68f03b5180 draft
Bugfix: Check that QRcode_encodeString didn't return NULL (error)
Without this, any error will segfault Bitcoin-Qt
author | Luke Dashjr <luke-jr+git@utopios.org> |
---|---|
date | Sat, 14 Apr 2012 21:00:27 -0400 |
parents | b6080d41c33b |
children | 31909edc9c0b |
files | src/qt/qrcodedialog.cpp |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/qt/qrcodedialog.cpp +++ b/src/qt/qrcodedialog.cpp @@ -38,12 +38,16 @@ { 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 @@ 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()