Skip to content

Commit ce1cb9f

Browse files
committed
fix: initialize seed and reset state in PYXXH32_new and PYXXH64_new
For consistency with XXH3_64 and XXH3_128 implementations, tp_new now initializes self->seed = 0 and resets the internal state. This ensures the object is in a valid state even if __init__ is bypassed (e.g. via __new__ directly or subclassing without calling super().__init__).
1 parent b2698c2 commit ce1cb9f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/_xxhash.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ static PyObject *PYXXH32_new(PyTypeObject *type, PyObject *args, PyObject *kwarg
415415
return NULL;
416416
}
417417

418+
self->seed = 0;
419+
XXH32_reset(self->xxhash_state, 0);
420+
418421
return (PyObject *)self;
419422
}
420423

@@ -719,6 +722,9 @@ static PyObject *PYXXH64_new(PyTypeObject *type, PyObject *args, PyObject *kwarg
719722
return NULL;
720723
}
721724

725+
self->seed = 0;
726+
XXH64_reset(self->xxhash_state, 0);
727+
722728
return (PyObject *)self;
723729
}
724730

0 commit comments

Comments
 (0)