Skip to content

Commit 5351994

Browse files
committed
fix: reject extra positional args in update()
1 parent 90e033f commit 5351994

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/_xxhash.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,11 @@ static PyObject *PYXXH32_update(PYXXH32Object *self, PyObject *const *args,
571571
PyObject *arg;
572572

573573
if (nargs >= 1) {
574+
if (nargs > 1) {
575+
PyErr_Format(PyExc_TypeError,
576+
"xxh32.update() takes at most 1 positional argument (%zd given)", nargs);
577+
return NULL;
578+
}
574579
arg = args[0];
575580
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
576581
PyErr_SetString(PyExc_TypeError,
@@ -951,6 +956,11 @@ static PyObject *PYXXH64_update(PYXXH64Object *self, PyObject *const *args,
951956
PyObject *arg;
952957

953958
if (nargs >= 1) {
959+
if (nargs > 1) {
960+
PyErr_Format(PyExc_TypeError,
961+
"xxh64.update() takes at most 1 positional argument (%zd given)", nargs);
962+
return NULL;
963+
}
954964
arg = args[0];
955965
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
956966
PyErr_SetString(PyExc_TypeError,
@@ -1330,6 +1340,11 @@ static PyObject *PYXXH3_64_update(PYXXH3_64Object *self, PyObject *const *args,
13301340
PyObject *arg;
13311341

13321342
if (nargs >= 1) {
1343+
if (nargs > 1) {
1344+
PyErr_Format(PyExc_TypeError,
1345+
"xxh3_64.update() takes at most 1 positional argument (%zd given)", nargs);
1346+
return NULL;
1347+
}
13331348
arg = args[0];
13341349
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
13351350
PyErr_SetString(PyExc_TypeError,
@@ -1718,6 +1733,11 @@ static PyObject *PYXXH3_128_update(PYXXH3_128Object *self, PyObject *const *args
17181733
PyObject *arg;
17191734

17201735
if (nargs >= 1) {
1736+
if (nargs > 1) {
1737+
PyErr_Format(PyExc_TypeError,
1738+
"xxh3_128.update() takes at most 1 positional argument (%zd given)", nargs);
1739+
return NULL;
1740+
}
17211741
arg = args[0];
17221742
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
17231743
PyErr_SetString(PyExc_TypeError,

0 commit comments

Comments
 (0)