QDBusDemarshaller: use RAII in duplicate()

QtDBus is compiled with exceptions disabled, but checkers
don't know that, and it's not 100% certain it will stay
that way until eternity.

So do the simple change and hold the new'ed pointer in a
QScopedPointer until handing it off to create().

Coverity-Id: 154477
Change-Id: I91a763ca4e93585c97cb9e794312b53046971161
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2016-09-15 09:43:01 +02:00
parent 0bf0c3e184
commit 0f21e0bc19
1 changed files with 5 additions and 2 deletions

View File

@ -33,6 +33,9 @@
#include "qdbusargument_p.h"
#include "qdbusconnection.h"
#include <qscopedpointer.h>
#include <stdlib.h>
QT_BEGIN_NAMESPACE
@ -417,12 +420,12 @@ QDBusDemarshaller *QDBusDemarshaller::endCommon()
QDBusArgument QDBusDemarshaller::duplicate()
{
QDBusDemarshaller *d = new QDBusDemarshaller(capabilities);
QScopedPointer<QDBusDemarshaller> d(new QDBusDemarshaller(capabilities));
d->iterator = iterator;
d->message = q_dbus_message_ref(message);
q_dbus_message_iter_next(&iterator);
return QDBusArgumentPrivate::create(d);
return QDBusArgumentPrivate::create(d.take());
}
QT_END_NAMESPACE