Skip to content

Commit 0cf3cdc

Browse files
committed
Slightly more logic order in IGzipReader__new__
1 parent 485a97a commit 0cf3cdc

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/isal/isal_zlibmodule.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,30 +1281,28 @@ IGzipReader__new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
12811281
return NULL;
12821282
}
12831283
IGzipReader *self = PyObject_New(IGzipReader, type);
1284-
self->current_pos = NULL;
1285-
self->buffer_end = NULL;
1284+
self->buffer_size = buffer_size;
1285+
self->input_buffer = PyMem_Malloc(self->buffer_size);
1286+
if (self->input_buffer == NULL) {
1287+
Py_DECREF(self);
1288+
return PyErr_NoMemory();
1289+
}
1290+
self->current_pos = self->input_buffer;
1291+
self->buffer_end = self->current_pos;
1292+
self->_pos = 0;
1293+
self->_size = -1;
12861294
Py_INCREF(fp);
12871295
self->fp = fp;
1288-
self->_pos = 0;
12891296
self->stream_phase = IGZIPREADER_HEADER;
12901297
self->all_bytes_read = 0;
1291-
self->_size = -1;
1292-
self->_last_mtime = 0;
12931298
self->closed = 0;
1299+
self->_last_mtime = 0;
12941300
self->lock = PyThread_allocate_lock();
12951301
if (self->lock == NULL) {
12961302
Py_DECREF(self);
12971303
PyErr_SetString(PyExc_MemoryError, "Unable to allocate lock");
12981304
return NULL;
12991305
}
1300-
self->buffer_size = buffer_size;
1301-
self->input_buffer = PyMem_Malloc(self->buffer_size);
1302-
if (self->input_buffer == NULL) {
1303-
Py_DECREF(self);
1304-
return PyErr_NoMemory();
1305-
}
1306-
self->current_pos = self->input_buffer;
1307-
self->buffer_end = self->current_pos;
13081306
isal_inflate_init(&self->state);
13091307
self->state.hist_bits = ISAL_DEF_MAX_HIST_BITS;
13101308
self->state.crc_flag = ISAL_GZIP_NO_HDR;

0 commit comments

Comments
 (0)