Prevent more NULL ptr accesses due to Balloc out of memory
- fix gdtoa-gethex.c, ldtoa.c, and strtodg.c to use eBalloc
This commit is contained in:
parent
1afb22a120
commit
1fdf871c9d
@ -129,7 +129,7 @@ increment (struct _reent *ptr,
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (b->_wds >= b->_maxwds) {
|
if (b->_wds >= b->_maxwds) {
|
||||||
b1 = Balloc(ptr, b->_k+1);
|
b1 = eBalloc(ptr, b->_k+1);
|
||||||
Bcopy(b1, b);
|
Bcopy(b1, b);
|
||||||
Bfree(ptr, b);
|
Bfree(ptr, b);
|
||||||
b = b1;
|
b = b1;
|
||||||
@ -219,7 +219,7 @@ gethex (struct _reent *ptr, const char **sp, const FPI *fpi,
|
|||||||
n = s1 - s0 - 1;
|
n = s1 - s0 - 1;
|
||||||
for(k = 0; n > 7; n >>= 1)
|
for(k = 0; n > 7; n >>= 1)
|
||||||
k++;
|
k++;
|
||||||
b = Balloc(ptr, k);
|
b = eBalloc(ptr, k);
|
||||||
x = b->_x;
|
x = b->_x;
|
||||||
n = 0;
|
n = 0;
|
||||||
L = 0;
|
L = 0;
|
||||||
|
@ -2923,7 +2923,7 @@ stripspaces:
|
|||||||
for (_REENT_MP_RESULT_K (ptr) = 0;
|
for (_REENT_MP_RESULT_K (ptr) = 0;
|
||||||
sizeof (_Bigint) - sizeof (__ULong) + j <= i; j <<= 1)
|
sizeof (_Bigint) - sizeof (__ULong) + j <= i; j <<= 1)
|
||||||
_REENT_MP_RESULT_K (ptr)++;
|
_REENT_MP_RESULT_K (ptr)++;
|
||||||
_REENT_MP_RESULT (ptr) = Balloc (ptr, _REENT_MP_RESULT_K (ptr));
|
_REENT_MP_RESULT (ptr) = eBalloc (ptr, _REENT_MP_RESULT_K (ptr));
|
||||||
|
|
||||||
/* Copy from internal temporary buffer to permanent buffer. */
|
/* Copy from internal temporary buffer to permanent buffer. */
|
||||||
outstr = (char *) _REENT_MP_RESULT (ptr);
|
outstr = (char *) _REENT_MP_RESULT (ptr);
|
||||||
|
@ -63,7 +63,7 @@ sum (struct _reent *p, _Bigint *a, _Bigint *b)
|
|||||||
if (a->_wds < b->_wds) {
|
if (a->_wds < b->_wds) {
|
||||||
c = b; b = a; a = c;
|
c = b; b = a; a = c;
|
||||||
}
|
}
|
||||||
c = Balloc(p, a->_k);
|
c = eBalloc(p, a->_k);
|
||||||
c->_wds = a->_wds;
|
c->_wds = a->_wds;
|
||||||
carry = 0;
|
carry = 0;
|
||||||
xa = a->_x;
|
xa = a->_x;
|
||||||
@ -103,7 +103,7 @@ sum (struct _reent *p, _Bigint *a, _Bigint *b)
|
|||||||
#endif
|
#endif
|
||||||
if (carry) {
|
if (carry) {
|
||||||
if (c->_wds == c->_maxwds) {
|
if (c->_wds == c->_maxwds) {
|
||||||
b = Balloc(p, c->_k + 1);
|
b = eBalloc(p, c->_k + 1);
|
||||||
Bcopy(b, c);
|
Bcopy(b, c);
|
||||||
Bfree(p, c);
|
Bfree(p, c);
|
||||||
c = b;
|
c = b;
|
||||||
@ -190,7 +190,7 @@ increment (struct _reent *p, _Bigint *b)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (b->_wds >= b->_maxwds) {
|
if (b->_wds >= b->_maxwds) {
|
||||||
b1 = Balloc(p,b->_k+1);
|
b1 = eBalloc(p,b->_k+1);
|
||||||
Bcopy(b1,b);
|
Bcopy(b1,b);
|
||||||
Bfree(p,b);
|
Bfree(p,b);
|
||||||
b = b1;
|
b = b1;
|
||||||
@ -253,7 +253,7 @@ set_ones (struct _reent *p, _Bigint *b, int n)
|
|||||||
k = (n + ((1 << kshift) - 1)) >> kshift;
|
k = (n + ((1 << kshift) - 1)) >> kshift;
|
||||||
if (b->_k < k) {
|
if (b->_k < k) {
|
||||||
Bfree(p,b);
|
Bfree(p,b);
|
||||||
b = Balloc(p,k);
|
b = eBalloc(p,k);
|
||||||
}
|
}
|
||||||
k = n >> kshift;
|
k = n >> kshift;
|
||||||
if (n &= kmask)
|
if (n &= kmask)
|
||||||
@ -792,9 +792,9 @@ _strtodg_l (struct _reent *p, const char *s00, char **se, FPI *fpi, Long *exp,
|
|||||||
bd0 = s2b(p, s0, nd0, nd, y);
|
bd0 = s2b(p, s0, nd0, nd, y);
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
bd = Balloc(p,bd0->_k);
|
bd = eBalloc(p,bd0->_k);
|
||||||
Bcopy(bd, bd0);
|
Bcopy(bd, bd0);
|
||||||
bb = Balloc(p,rvb->_k);
|
bb = eBalloc(p,rvb->_k);
|
||||||
Bcopy(bb, rvb);
|
Bcopy(bb, rvb);
|
||||||
bbbits = rvbits - bb0;
|
bbbits = rvbits - bb0;
|
||||||
bbe = rve + bb0;
|
bbe = rve + bb0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user