From 9ad85010bfa7c03147b57028705319f312f84ae8 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Tue, 27 Feb 2024 19:31:13 +0900 Subject: [PATCH] Fix leak of tmp values in long.__truediv__ --- src/obj_long.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/obj_long.c b/src/obj_long.c index 5ac2f020..6b91ce07 100644 --- a/src/obj_long.c +++ b/src/obj_long.c @@ -1436,7 +1436,9 @@ KRK_Method(long,__truediv__) { else if (IS_INTEGER(argv[1])) krk_long_init_si(tmp, AS_INTEGER(argv[1])); else if (IS_FLOATING(argv[1])) return checked_float_div(krk_long_get_double(self->value), AS_FLOATING(argv[1])); else return NOTIMPL_VAL(); - return _krk_long_truediv(self->value,tmp); + KrkValue result = _krk_long_truediv(self->value,tmp); + krk_long_clear(tmp); + return result; } KRK_Method(long,__rtruediv__) { @@ -1445,7 +1447,9 @@ KRK_Method(long,__rtruediv__) { else if (IS_INTEGER(argv[1])) krk_long_init_si(tmp, AS_INTEGER(argv[1])); else if (IS_FLOATING(argv[1])) return checked_float_div(AS_FLOATING(argv[1]), krk_long_get_double(self->value)); else return NOTIMPL_VAL(); - return _krk_long_truediv(tmp,self->value); + KrkValue result = _krk_long_truediv(tmp,self->value); + krk_long_clear(tmp); + return result; } #endif