Skip to content

Commit 90e033f

Browse files
committed
fix: reject duplicate data arg in update()
1 parent 9163598 commit 90e033f

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/_xxhash.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ static PyObject *PYXXH32_update(PYXXH32Object *self, PyObject *const *args,
572572

573573
if (nargs >= 1) {
574574
arg = args[0];
575+
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
576+
PyErr_SetString(PyExc_TypeError,
577+
"xxh32.update() got multiple values for argument 'data'");
578+
return NULL;
579+
}
575580
} else if (kwnames && PyTuple_GET_SIZE(kwnames) == 1 &&
576581
PyUnicode_CompareWithASCIIString(PyTuple_GET_ITEM(kwnames, 0), "data") == 0) {
577582
arg = args[0];
@@ -947,6 +952,11 @@ static PyObject *PYXXH64_update(PYXXH64Object *self, PyObject *const *args,
947952

948953
if (nargs >= 1) {
949954
arg = args[0];
955+
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
956+
PyErr_SetString(PyExc_TypeError,
957+
"xxh64.update() got multiple values for argument 'data'");
958+
return NULL;
959+
}
950960
} else if (kwnames && PyTuple_GET_SIZE(kwnames) == 1 &&
951961
PyUnicode_CompareWithASCIIString(PyTuple_GET_ITEM(kwnames, 0), "data") == 0) {
952962
arg = args[0];
@@ -1321,11 +1331,16 @@ static PyObject *PYXXH3_64_update(PYXXH3_64Object *self, PyObject *const *args,
13211331

13221332
if (nargs >= 1) {
13231333
arg = args[0];
1334+
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
1335+
PyErr_SetString(PyExc_TypeError,
1336+
"xxh3_64.update() got multiple values for argument 'data'");
1337+
return NULL;
1338+
}
13241339
} else if (kwnames && PyTuple_GET_SIZE(kwnames) == 1 &&
13251340
PyUnicode_CompareWithASCIIString(PyTuple_GET_ITEM(kwnames, 0), "data") == 0) {
13261341
arg = args[0];
13271342
} else {
1328-
PyErr_SetString(PyExc_TypeError, "xxhxxh364.update() missing required argument 'data'");
1343+
PyErr_SetString(PyExc_TypeError, "xxh3_64.update() missing required argument 'data'");
13291344
return NULL;
13301345
}
13311346

@@ -1704,11 +1719,16 @@ static PyObject *PYXXH3_128_update(PYXXH3_128Object *self, PyObject *const *args
17041719

17051720
if (nargs >= 1) {
17061721
arg = args[0];
1722+
if (kwnames && PyTuple_GET_SIZE(kwnames) > 0) {
1723+
PyErr_SetString(PyExc_TypeError,
1724+
"xxh3_128.update() got multiple values for argument 'data'");
1725+
return NULL;
1726+
}
17071727
} else if (kwnames && PyTuple_GET_SIZE(kwnames) == 1 &&
17081728
PyUnicode_CompareWithASCIIString(PyTuple_GET_ITEM(kwnames, 0), "data") == 0) {
17091729
arg = args[0];
17101730
} else {
1711-
PyErr_SetString(PyExc_TypeError, "xxhxxh3128.update() missing required argument 'data'");
1731+
PyErr_SetString(PyExc_TypeError, "xxh3_128.update() missing required argument 'data'");
17121732
return NULL;
17131733
}
17141734

0 commit comments

Comments
 (0)