From 128d970d60dfc8bb89e8ca8b4d150bfee5ca4d7b Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 21 Jan 2026 20:48:30 -0800 Subject: [PATCH] Remove memory leak when checking if a package has any dumpable items --- vpi/sys_vcd.c | 2 +- vpi/vcd_priv.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 61f0db4a5..3eece52a0 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -676,7 +676,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip) case vpiParameter: - /* If we are skipping all pamaeters then just return. */ + /* If we are skipping all parameters then just return. */ if (skip) return; size = vpi_get(vpiSize, item); diff --git a/vpi/vcd_priv.c b/vpi/vcd_priv.c index 75d53bc63..00af4cf70 100644 --- a/vpi/vcd_priv.c +++ b/vpi/vcd_priv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2025 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2026 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -51,12 +51,16 @@ int is_escaped_id(const char *name) return 1; } +/* Check if there are any things that could be dumped in this item. */ int vcd_instance_contains_dumpable_items(const int dumpable_types[], vpiHandle item) { int i; for (i = 0; dumpable_types[i] > 0; i++) { - if (vpi_iterate(dumpable_types[i], item)) - return 1; + vpiHandle iter = vpi_iterate(dumpable_types[i], item); + if (iter) { + vpi_release_handle(iter); + return 1; + } } return 0; }