From f7175298830357da388a4f4fde1d73409f91a729 Mon Sep 17 00:00:00 2001 From: Ville Nummela Date: Tue, 19 May 2020 17:06:56 +0300 Subject: [PATCH] IppMsg: Don't encode job attributes if there are none --- src/ippmsg.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ippmsg.cpp b/src/ippmsg.cpp index 654fe22..ad59572 100644 --- a/src/ippmsg.cpp +++ b/src/ippmsg.cpp @@ -199,12 +199,14 @@ QByteArray IppMsg::encode(Operation op) } for(QJsonArray::iterator ait = _jobAttrs.begin(); ait != _jobAttrs.end(); ait++) { - ipp << quint8(2); QJsonObject tmpObj = ait->toObject(); - for(QJsonObject::iterator it = tmpObj.begin(); it != tmpObj.end(); it++) - { - QJsonObject val = it.value().toObject(); - ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]); + if (!tmpObj.isEmpty()) { + ipp << quint8(2); + for(QJsonObject::iterator it = tmpObj.begin(); it != tmpObj.end(); it++) + { + QJsonObject val = it.value().toObject(); + ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]); + } } }