From 5db2a2fa3a121b0b550fae42cb082c3774bcc80f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 18 Jun 2021 14:18:48 +0200 Subject: only reallocate when full --- rpminfo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'rpminfo.c') diff --git a/rpminfo.c b/rpminfo.c index fa5a8de..3aa7e36 100644 --- a/rpminfo.c +++ b/rpminfo.c @@ -36,6 +36,7 @@ #define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \ ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null) #endif + #include "rpminfo_arginfo.h" ZEND_DECLARE_MODULE_GLOBALS(rpminfo) @@ -510,8 +511,10 @@ PHP_FUNCTION(rpmaddtag) RETURN_BOOL(0); } } - RPMINFO_G(max_tags) += 16; - RPMINFO_G(tags) = erealloc(RPMINFO_G(tags), RPMINFO_G(max_tags) * sizeof(rpmTagVal)); + if (RPMINFO_G(nb_tags) == RPMINFO_G(max_tags)) { + RPMINFO_G(max_tags) += 16; + RPMINFO_G(tags) = erealloc(RPMINFO_G(tags), RPMINFO_G(max_tags) * sizeof(rpmTagVal)); + } } else { RPMINFO_G(max_tags) = 16; RPMINFO_G(tags) = emalloc(RPMINFO_G(max_tags) * sizeof(rpmTagVal)); -- cgit