Skip to content

Commit 485a97a

Browse files
committed
Fix writing to the wrong ptr
1 parent 0c1c590 commit 485a97a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/isal/isal_zlibmodule.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,15 +1669,18 @@ IGzipReader_readall(IGzipReader *self, PyObject *Py_UNUSED(ignore))
16691669
goto readall_finish;
16701670
}
16711671
total_size += written_size;
1672-
chunk_list[number_of_chunks] = chunk;
1673-
number_of_chunks += 1;
1672+
16741673
if (written_size < chunk_size) {
16751674
// Reached the end, resize the smaller chunk
16761675
if (_PyBytes_Resize(&chunk, written_size) < 0) {
16771676
goto readall_finish;
16781677
}
1678+
chunk_list[number_of_chunks] = chunk;
1679+
number_of_chunks += 1;
16791680
break;
16801681
}
1682+
chunk_list[number_of_chunks] = chunk;
1683+
number_of_chunks += 1;
16811684
chunk_size *= 2;
16821685
}
16831686
if (number_of_chunks == 1) {
@@ -1693,7 +1696,7 @@ IGzipReader_readall(IGzipReader *self, PyObject *Py_UNUSED(ignore))
16931696
for (size_t i=0; i < number_of_chunks; i++) {
16941697
PyObject *chunk = chunk_list[i];
16951698
Py_ssize_t chunk_size = PyBytes_GET_SIZE(chunk);
1696-
memcpy(ret, PyBytes_AS_STRING(chunk), chunk_size);
1699+
memcpy(ret_ptr, PyBytes_AS_STRING(chunk), chunk_size);
16971700
ret_ptr += chunk_size;
16981701
}
16991702
readall_finish:

0 commit comments

Comments
 (0)