callocMustSucceed suspends thread if 0 bytes are requested

Bug #541320 reported by Dirk Zimoch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
High
Andrew Johnson

Bug Description

The release notes say:
"mallocMustSucceed and callocMustSucceed accept 0-byte requests. Note that these routines may return a NULL pointer in such cases."
But the code does this:
    if (count == 0 || size == 0)
        cantProceed("%s: callocMustSucceed(%lu, %lu) - bad args\n",
                msg, (unsigned long)count, (unsigned long)size);

This crashes applications that assumes it is safe to allocate 0 bytes. I noticed that when I tried to start an "empty" IOC (no records defined).

Fix is simple:
if (count == 0 || size == 0) return NULL;

Original Mantis Bug: mantis-290
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=290

Tags: 3.14
Revision history for this message
Dirk Zimoch (dirk.zimoch) wrote :

I forgot to say that the bug is new in 3.14.9.

Revision history for this message
Andrew Johnson (anj) wrote :

Fixed in R3.14.10.

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.10 released.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.