Commit c206c766 authored by Guido van Rossum's avatar Guido van Rossum

fix memory leak and null pointer dereference

parent 946805d4
...@@ -523,6 +523,8 @@ int_pow(v, w, z) ...@@ -523,6 +523,8 @@ int_pow(v, w, z)
XDECREF(t2); XDECREF(t2);
return(NULL); return(NULL);
} }
DECREF(t1);
DECREF(t2);
ix=mod; ix=mod;
} }
return newintobject(ix); return newintobject(ix);
......
...@@ -552,7 +552,9 @@ x_divrem(v1, w1, prem) ...@@ -552,7 +552,9 @@ x_divrem(v1, w1, prem)
} }
} /* for j, k */ } /* for j, k */
if (a != NULL) { if (a == NULL)
*prem = NULL;
else {
a = long_normalize(a); a = long_normalize(a);
*prem = divrem1(v, d, &d); *prem = divrem1(v, d, &d);
/* d receives the (unused) remainder */ /* d receives the (unused) remainder */
...@@ -1001,7 +1003,7 @@ long_pow(a, b, c) ...@@ -1001,7 +1003,7 @@ long_pow(a, b, c)
break; break;
} }
} }
if (a == NULL) if (a == NULL || z == NULL)
break; break;
} }
XDECREF(a); XDECREF(a);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment