VirtualBox

Ignore:
Timestamp:
Nov 18, 2015 10:24:35 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
104171
Message:

libs/xpcom: fix (just in case) for sloppy code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/lib/ds/plarena.h

    r1 r58734  
    109109    PR_BEGIN_MACRO \
    110110        PLArena *_a = (pool)->current; \
    111         PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \
     111        PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \
    112112        PRUword _p = _a->avail; \
    113         PRUword _q = _p + _nb; \
    114         if (_q > _a->limit) \
     113        if (_nb < (PRUint32)nb) { \
     114            _p = 0; \
     115        } else if (_nb > (_a->limit - _a->avail)) { \
    115116            _p = (PRUword)PL_ArenaAllocate(pool, _nb); \
    116         else \
    117             _a->avail = _q; \
     117        } else { \
     118            _a->avail += _nb; \
     119        } \
    118120        p = (void *)_p; \
    119         PL_ArenaCountAllocation(pool, nb); \
     121        if (p) { \
     122            PL_ArenaCountAllocation(pool, nb); \
     123        } \
    120124    PR_END_MACRO
    121125
     
    123127    PR_BEGIN_MACRO \
    124128        PLArena *_a = (pool)->current; \
    125         PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \
    126         PRUword _p = _a->avail; \
    127         PRUword _q = _p + _incr; \
    128         if (_p == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
    129             _q <= _a->limit) { \
    130             _a->avail = _q; \
    131             PL_ArenaCountInplaceGrowth(pool, size, incr); \
     129        PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \
     130        if (_incr < (PRUint32)incr) { \
     131            p = NULL; \
     132        } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
     133            _incr <= (_a->limit - _a->avail)) { \
     134            _a->avail = _incr; \
     135            PL_ArenaCountInplaceGrowth(pool, size, (RTUint32)incr); \
    132136        } else { \
    133             p = PL_ArenaGrow(pool, p, size, incr); \
    134         } \
    135         PL_ArenaCountGrowth(pool, size, incr); \
     137            p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \
     138        } \
     139        if (p) { \
     140            PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \
     141        } \
    136142    PR_END_MACRO
    137143
Note: See TracChangeset for help on using the changeset viewer.

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