From d4baf1f95b811f40773f5df0d8780fb2111ba6f5 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Thu, 22 Aug 2019 10:56:38 +0200 Subject: [PATCH] Fix ZstdDecompressor on 64-bit big-endian 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. --- c-ext/decompressor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c-ext/decompressor.c b/c-ext/decompressor.c index ecf037cc..d7d5f867 100644 --- a/c-ext/decompressor.c +++ b/c-ext/decompressor.c @@ -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; }