Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Modules/binascii.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,7 +66,7 @@ typedef struct binascii_state{
PyObject *Incomplete;
} binascii_state;

static binascii_state *
static inline binascii_state *
get_binascii_state(PyObject *module)
{
return (binascii_state *)PyModule_GetState(module);
Expand DownExpand Up@@ -312,7 +312,7 @@ binascii_a2b_uu_impl(PyObject *module, Py_buffer *data)
** '`' as zero instead of space.
*/
if ( this_ch < ' ' || this_ch > (' ' + 64)){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand DownExpand Up@@ -344,7 +344,7 @@ binascii_a2b_uu_impl(PyObject *module, Py_buffer *data)
/* Extra '`' may be written as padding in some cases */
if ( this_ch != ' ' && this_ch != ' '+64 &&
this_ch != '\n' && this_ch != '\r' ){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand DownExpand Up@@ -385,7 +385,7 @@ binascii_b2a_uu_impl(PyObject *module, Py_buffer *data, int backtick)
bin_len = data->len;
if ( bin_len > 45 ){
/* The 45 is a limit that appears in all uuencode's */
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand DownExpand Up@@ -505,9 +505,9 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data)
}

if (quad_pos != 0){
binascii_state *state = PyModule_GetState(module);
binascii_state *state = get_binascii_state(module);
if (state == NULL){
/* error already set, from PyModule_GetState */
/* error already set, from get_binascii_state */
} else if (quad_pos == 1){
/*
** There is exactly one extra valid, non-padding, base64 character.
Expand DownExpand Up@@ -562,7 +562,7 @@ binascii_b2a_base64_impl(PyObject *module, Py_buffer *data, int newline)
assert(bin_len >= 0);

if ( bin_len > BASE64_MAXBIN ){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand DownExpand Up@@ -657,7 +657,7 @@ binascii_a2b_hqx_impl(PyObject *module, Py_buffer *data)
if ( this_ch == SKIP )
continue;
if ( this_ch == FAIL ){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand All@@ -682,7 +682,7 @@ binascii_a2b_hqx_impl(PyObject *module, Py_buffer *data)
}

if ( leftbits && !done ){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand DownExpand Up@@ -878,7 +878,7 @@ binascii_rledecode_hqx_impl(PyObject *module, Py_buffer *data)
#define INBYTE(b) \
do{\
if ( --in_len < 0 ){\
state = PyModule_GetState(module); \
state = get_binascii_state(module); \
if (state == NULL){\
return NULL; \
} \
Expand All@@ -904,7 +904,7 @@ binascii_rledecode_hqx_impl(PyObject *module, Py_buffer *data)
/* Note Error, not Incomplete (which is at the end
** of the string only). This is a programmer error.
*/
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand DownExpand Up@@ -1235,7 +1235,7 @@ binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr)
* raise an exception.
*/
if (arglen % 2){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand All@@ -1252,7 +1252,7 @@ binascii_a2b_hex_impl(PyObject *module, Py_buffer *hexstr)
unsigned int top = _PyLong_DigitValue[Py_CHARMASK(argbuf[i])];
unsigned int bot = _PyLong_DigitValue[Py_CHARMASK(argbuf[i+1])];
if (top >= 16 || bot >= 16){
state = PyModule_GetState(module);
state = get_binascii_state(module);
if (state == NULL){
return NULL;
}
Expand Down