Skip to content

Commit

Permalink
Fix ZstdDecompressor on 64-bit big-endian
Browse files Browse the repository at this point in the history
When parsing the python arguments, using "I" (int) in the format string
but passing a pointer to size_t means that, on big endian, we're only
initializing the high-order bits of the size_t.  Use "n" (Py_ssize_t)
format instead, which should be the right size.
  • Loading branch information
jcristau authored and indygreg committed Aug 23, 2019
1 parent 4675a2c commit d4baf1f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions c-ext/decompressor.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ static int Decompressor_init(ZstdDecompressor* self, PyObject* args, PyObject* k
};

ZstdCompressionDict* dict = NULL;
size_t maxWindowSize = 0;
Py_ssize_t maxWindowSize = 0;
ZSTD_format_e format = ZSTD_f_zstd1;

self->dctx = NULL;
self->dict = NULL;

if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O!II:ZstdDecompressor", kwlist,
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|O!nI:ZstdDecompressor", kwlist,
&ZstdCompressionDictType, &dict, &maxWindowSize, &format)) {
return -1;
}
Expand Down

0 comments on commit d4baf1f

Please sign in to comment.