VirtualBox

Changeset 86273 in vbox


Ignore:
Timestamp:
Sep 24, 2020 5:38:58 PM (4 years ago)
Author:
vboxsync
Message:

xpcom/prmem.c: The java bridge allocates zero byte for an array, resulting in assertion + allocation error. Do a RT_MAX(size,1) to ensure that RTMemAlloc[Z] doesn't assert and returns a non-NULL value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/malloc/prmem.c

    r31259 r86273  
    470470
    471471#ifdef VBOX_USE_IPRT_IN_NSPR
    472     return use_zone_allocator ? pr_ZoneMalloc(size) : RTMemAlloc(size);
     472    return use_zone_allocator ? pr_ZoneMalloc(size) : RTMemAlloc(RT_MAX(size, 1));
    473473#else
    474474    return use_zone_allocator ? pr_ZoneMalloc(size) : malloc(size);
     
    482482    return use_zone_allocator ?
    483483#ifdef VBOX_USE_IPRT_IN_NSPR
    484         pr_ZoneCalloc(nelem, elsize) : RTMemAllocZ(nelem * (size_t)elsize);
     484        pr_ZoneCalloc(nelem, elsize) : RTMemAllocZ(RT_MAX(nelem * (size_t)elsize, 1));
    485485#else
    486486        pr_ZoneCalloc(nelem, elsize) : calloc(nelem, elsize);
     
    527527#else
    528528# ifdef VBOX_USE_IPRT_IN_NSPR
    529     return RTMemAlloc(size);
     529    return RTMemAlloc(RT_MAX(size, 1));
    530530# else
    531531    return malloc(size);
     
    541541#else
    542542# ifdef VBOX_USE_IPRT_IN_NSPR
    543     return RTMemAllocZ(nelem * (size_t)elsize);
     543    return RTMemAllocZ(RT_MAX(nelem * (size_t)elsize, 1));
    544544# else
    545545    return calloc(nelem, elsize);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette