[LLVMbugs] [Bug 13358] New: scan-build does not find a leak

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 13 11:02:28 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13358

             Bug #: 13358
           Summary: scan-build does not find a leak
           Product: clang
           Version: trunk
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: johannesobermayr at gmx.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


http://cgit.freedesktop.org/mesa/drm

drm_context_t *drmGetReservedContextList(int fd, int *count)
{
    drm_ctx_res_t res;
    drm_ctx_t     *list;
    drm_context_t * retval;
    int           i;

    res.count    = 0;
    res.contexts = NULL;
    if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res))
        return NULL;

    if (!res.count)
        return NULL;

    if (!(list   = drmMalloc(res.count * sizeof(*list))))
        return NULL;
    if (!(retval = drmMalloc(res.count * sizeof(*retval)))) {
        drmFree(list);
        return NULL;
    }

    res.contexts = list;
    if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res)) {
        drmFree(retval);
-> here is 'list' leaking ...
-> see: http://lists.freedesktop.org/archives/mesa-dev/2012-June/023458.html
        return NULL;
    }

    for (i = 0; i < res.count; i++)
        retval[i] = list[i].handle;
    drmFree(list);

    *count = res.count;
    return retval;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list