Commit be119c0f authored by Michael Pyne's avatar Michael Pyne

Avoid using uninitialized tempfile buffer.

If the PPD filename were null then we wouldn't fill in the tempfile
buffer and since we don't bail out early we'd later try to unlink
whatever file might be named by bytes in that buffer. Caught by
Coverity, CID 1335203

Also, the filename checks should use QString::isEmpty instead of
QString::isNull, given the logic of the relevant checks.
parent e330a88b
......@@ -78,7 +78,7 @@ void PrinterOptions::on_autoConfigurePB_clicked()
void PrinterOptions::reloadPPD()
// The caller "owns" the file that is created and must unlink the returned filename.
if (!m_filename.isNull()) {
if (!m_filename.isEmpty()) {
......@@ -393,7 +393,7 @@ PrinterOptions::~PrinterOptions()
if (!m_filename.isNull()) {
if (!m_filename.isEmpty()) {
......@@ -706,7 +706,7 @@ void PrinterOptions::save()
*keyptr; /* Pointer into keyword... */
// copy cups-1.4.2/cgi-bin line 3779
if (!m_filename.isNull()) {
if (!m_filename.isEmpty()) {
out = cupsTempFile2(tempfile, sizeof(tempfile));
in = cupsFileOpen(m_filename.toUtf8(), "r");
......@@ -764,6 +764,12 @@ void PrinterOptions::save()
else {
// TODO add a KMessageBox::error
qCWarning(PM_CONFIGURE_PRINTER) << "No printer PPD file set, can't save options.";
QVariantHash values; // we need null values
QPointer<KCupsRequest> request = new KCupsRequest;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment