Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SystemError for PY_SSIZE_T_CLEAN in fastlz.decompress #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "fastlz"]
path = fastlz
url = https://github.com/ariya/FastLZ.git
1 change: 1 addition & 0 deletions fastlz
Submodule fastlz added at 344eb4
8 changes: 5 additions & 3 deletions fastlz.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "fastlz/fastlz.h"

Expand All @@ -16,7 +17,8 @@ compress(PyObject *self, PyObject *args, PyObject *kwargs)
PyObject *result;
const char *input;
char *output;
int level = 0, input_len, output_len;
Py_ssize_t level = 0, input_len;
uint32_t output_len;

static char *arglist[] = {"string", "level", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s#|i", arglist, &input,
Expand Down Expand Up @@ -62,14 +64,14 @@ decompress(PyObject *self, PyObject *args)
{
PyObject *result;
const char *input;
int input_len;
Py_ssize_t input_len;
char *output;
uint32_t output_len, decompressed_len;

if (!PyArg_ParseTuple(args, "s#", &input, &input_len))
return NULL;

if ((uint32_t)input_len < sizeof(uint32_t)) {
if (input_len < (Py_ssize_t)sizeof(uint32_t)) {
PyErr_SetString(FastlzError, "invalid input");
return NULL;
}
Expand Down
24 changes: 0 additions & 24 deletions fastlz/LICENSE

This file was deleted.

75 changes: 0 additions & 75 deletions fastlz/README.TXT

This file was deleted.

Loading