[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] plug two leaks



"Daniel P. Berrange" <berrange redhat com> wrote:
> On Fri, May 16, 2008 at 06:44:48PM +0200, Jim Meyering wrote:
>> Running "make check" under valgrind exposed at least
>> the first.  Then, I spotted the other.
>
> ACK.

speedy ;-)
Committed.

Actually there's one more, but I don't have time for it right now:

     128 (96 direct, 32 indirect) bytes in 6 blocks are definitely lost in loss record 5 of 7
        at 0x4A05174: calloc (vg_replace_malloc.c:397)
        by 0x40A6EA: qemudParseVMDef (qemu_conf.c:2078)
        by 0x402991: testCompareXMLToArgvHelper (qemuxml2argvtest.c:43)
        by 0x4032C0: virtTestRun (testutils.c:79)
        by 0x402861: main (qemuxml2argvtest.c:180)

It's allocated with this calloc call:

    /* Parse sound driver xml */
    obj = xmlXPathEval(BAD_CAST "/domain/devices/sound", ctxt);
    if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
        (obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
        struct qemud_vm_sound_def *prev = NULL;
        for (i = 0; i < obj->nodesetval->nodeNr; i++) {

            struct qemud_vm_sound_def *sound = calloc(1, sizeof(*sound));
            struct qemud_vm_sound_def *check = def->sounds;
            int collision = 0;
            if (!sound) {
                qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
                         "%s", _("failed to allocate space for sound dev"));
                goto error;
            }
            if (qemudParseSoundXML(conn, sound,
                                   obj->nodesetval->nodeTab[i]) < 0) {
                free(sound);
                goto error;
            }

            // Check that model type isn't already present in sound dev list
            while(check) {
                if (check->model == sound->model) {
                    collision = 1;
                    break;
                }
                check = check->next;
            }
            if (collision)
                continue;

            def->nsounds++;
            sound->next = NULL;
            if (def->sounds == NULL) {
                def->sounds = sound;
            } else {
                prev->next = sound;
            }
            prev = sound;
        }
    }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]