On Wed, Sep 25, 2013 at 10:45:00AM -0600, Eric Blake wrote:
On 09/25/2013 08:51 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange(a)redhat.com>
>
> If virDBusMessageIterEncode hits an OOM condition it often
> leaks the memory associated with the dbus iterator object
>
> Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
> ---
>
> cleanup:
> + while (nstack > 0) {
> + DBusMessageIter *thisiter = iter;
> + VIR_DEBUG("Popping iter=%p", iter);
> + if (virDBusTypeStackPop(&stack, &nstack, &iter,
> + &types, &nstruct, &narray) < 0)
> + goto cleanup;
I'm worried that this will infloop. What guarantee do we have that
nstack reduces when virDBusTypeStackPop fails?
It can only return -1, if nstack == 0, so I think we're fine there
static int virDBusTypeStackPop(virDBusTypeStack **stack,
size_t *nstack,
DBusMessageIter **iter,
const char **types,
size_t *nstruct,
size_t *narray)
{
if (*nstack == 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("DBus type stack is empty"));
return -1;
}
*iter = (*stack)[(*nstack) - 1].iter;
*types = (*stack)[(*nstack) - 1].types;
*nstruct = (*stack)[(*nstack) - 1].nstruct;
*narray = (*stack)[(*nstack) - 1].narray;
VIR_DEBUG("Popped '%s'", *types);
VIR_SHRINK_N(*stack, *nstack, 1);
return 0;
}
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|