}
if (PyBytes_GET_SIZE(result) < (Py_ssize_t)newsize) {
- if (_PyBytes_Resize(&result, newsize) < 0) {
- if (total == 0) {
- Py_DECREF(result);
- return NULL;
- }
- PyErr_Clear();
- break;
- }
+ if (_PyBytes_Resize(&result, newsize) < 0)
+ return NULL; /* result has been freed */
}
Py_BEGIN_ALLOW_THREADS
errno = 0;
if (PyBytes_GET_SIZE(result) > total) {
if (_PyBytes_Resize(&result, total) < 0) {
/* This should never happen, but just in case */
- Py_DECREF(result);
return NULL;
}
}
}
if (n != size) {
- if (_PyBytes_Resize(&bytes, n) < 0) {
- Py_DECREF(bytes);
+ if (_PyBytes_Resize(&bytes, n) < 0)
return NULL;
- }
}
return (PyObject *) bytes;
}
*ascii_data++ = '\n'; /* Append a courtesy newline */
- if (_PyString_Resize(&rv,
+ /* rv is cleared on error */
+ (void)_PyString_Resize(&rv,
(ascii_data -
- (unsigned char *)PyString_AS_STRING(rv))) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
+ (unsigned char *)PyString_AS_STRING(rv)));
PyBuffer_Release(&pbin);
return rv;
}
** string instead; _PyString_Resize() won't do this for us.
*/
if (bin_len > 0) {
- if (_PyString_Resize(&rv, bin_len) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
+ /* rv is cleared on error */
+ (void)_PyString_Resize(&rv, bin_len);
}
else {
Py_DECREF(rv);
}
*ascii_data++ = '\n'; /* Append a courtesy newline */
- if (_PyString_Resize(&rv,
+ /* rv is cleared on error */
+ (void)_PyString_Resize(&rv,
(ascii_data -
- (unsigned char *)PyString_AS_STRING(rv))) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
+ (unsigned char *)PyString_AS_STRING(rv)));
PyBuffer_Release(&pbuf);
return rv;
}
Py_DECREF(rv);
return NULL;
}
+ /* rv is cleared on error */
if (_PyString_Resize(&rv,
(bin_data -
- (unsigned char *)PyString_AS_STRING(rv))) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
- if (rv) {
+ (unsigned char *)PyString_AS_STRING(rv))) == 0) {
PyObject *rrv = Py_BuildValue("Oi", rv, done);
PyBuffer_Release(&pascii);
Py_DECREF(rv);
}
}
}
- if (_PyString_Resize(&rv,
+ /* rv is cleared on error */
+ (void)_PyString_Resize(&rv,
(out_data -
- (unsigned char *)PyString_AS_STRING(rv))) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
+ (unsigned char *)PyString_AS_STRING(rv)));
PyBuffer_Release(&pbuf);
return rv;
}
leftchar <<= (6-leftbits);
*ascii_data++ = table_b2a_hqx[leftchar & 0x3f];
}
- if (_PyString_Resize(&rv,
+ /* rv is cleared on error */
+ (void)_PyString_Resize(&rv,
(ascii_data -
- (unsigned char *)PyString_AS_STRING(rv))) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
+ (unsigned char *)PyString_AS_STRING(rv)));
PyBuffer_Release(&pbin);
return rv;
}
if ( --out_len_left < 0 ) { \
if ( out_len > PY_SSIZE_T_MAX / 2) return PyErr_NoMemory(); \
if (_PyString_Resize(&rv, 2*out_len) < 0) \
- { Py_DECREF(rv); PyBuffer_Release(&pin); return NULL; } \
+ { PyBuffer_Release(&pin); return NULL; } \
out_data = (unsigned char *)PyString_AS_STRING(rv) \
+ out_len; \
out_len_left = out_len-1; \
OUTBYTE(in_byte);
}
}
- if (_PyString_Resize(&rv,
+ /* rv is cleared on error */
+ (void)_PyString_Resize(&rv,
(out_data -
- (unsigned char *)PyString_AS_STRING(rv))) < 0) {
- Py_DECREF(rv);
- rv = NULL;
- }
+ (unsigned char *)PyString_AS_STRING(rv)));
PyBuffer_Release(&pin);
return rv;
}
vsize + 1 + 1;
if (totalsize > PyString_GET_SIZE(out)) {
int offset = p - PyString_AS_STRING(out);
- _PyString_Resize(&out, totalsize + 1024);
+ if (_PyString_Resize(&out, totalsize + 1024))
+ goto exit;
p = PyString_AS_STRING(out) + offset;
}
memcpy(p, PyString_AS_STRING(key), ksize);
_PyString_Resize(&out, p - PyString_AS_STRING(out));
/* PyObject_Print(out, stdout, 0); */
-
+exit:
Py_XDECREF(keys);
Py_XDECREF(values);