Fix OSS-Fuzz #562721806: Use-of-uninitialized-value in zim_Time_Duration___unserialize (#23759)

LVAL cannot be read if the type is still UNDEF. Check initialization to
fix this.
Randomizer doesn't have this because it uses read_property.
This commit is contained in:
Nora Dossche authored and GitHub committed 2026-09-18 21:03:28 +02:00
1 parent bbb345b363
commit 8de697eb08
1 file changed
+3
+3
View File
@@ -171,6 +171,9 @@ PHP_METHOD(Time_Duration, __unserialize)
zval *seconds = OBJ_PROP_NUM(&duration->std, 0);
zval *nanoseconds = OBJ_PROP_NUM(&duration->std, 1);
zval *negative = OBJ_PROP_NUM(&duration->std, 2);
if (Z_ISUNDEF_P(seconds) || Z_ISUNDEF_P(nanoseconds) || Z_ISUNDEF_P(negative)) {
goto fail;
}
/* Verify that both properties are positive, since the timelib_duration_ctor_static() takes unsigned. */
if (Z_LVAL_P(seconds) < 0 || Z_LVAL_P(nanoseconds) < 0) {