[Bug 261679] libc/locale/xlocale.c: potential NULL pointer dereference in alloc_locale()

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 02 Feb 2022 16:59:49 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261679

            Bug ID: 261679
           Summary: libc/locale/xlocale.c: potential NULL pointer
                    dereference in alloc_locale()
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: phil.stone@gmx.com

/usr/src/lib/libc/locale/xlocale.c, line 191

static locale_t
alloc_locale(void)
{
        locale_t new = calloc(sizeof(struct _xlocale), 1);

        new->header.destructor = destruct_locale;
        new->monetary_locale_changed = 1;
        new->numeric_locale_changed = 1;
        return (new);
}

calloc() return value is not tested. Variable new is always dereferenced, even
in the (unexpected) case where it is NULL.

-- 
You are receiving this mail because:
You are the assignee for the bug.