From 9c75a4b96b564b111bcc3d878ab4b5355209c623 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 8 Jan 2015 16:09:55 -0800 Subject: [PATCH] Fix a memory leak when the dump file cannot be opened --- vpi/sys_fst.c | 4 +++- vpi/sys_lxt.c | 4 +++- vpi/sys_lxt2.c | 4 +++- vpi/sys_vcd.c | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/vpi/sys_fst.c b/vpi/sys_fst.c index 1ed7b7fa0..f8c26404f 100644 --- a/vpi/sys_fst.c +++ b/vpi/sys_fst.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2015 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 @@ -372,6 +372,8 @@ static void open_dumpfile(vpiHandle callh) (int)vpi_get(vpiLineNo, callh)); vpi_printf("Unable to open %s for output.\n", dump_path); vpi_control(vpiFinish, 1); + free(dump_path); + dump_path = 0; return; } else { int prec = vpi_get(vpiTimePrecision, 0); diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index 86068a8ee..e2c6969c2 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-2015 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 @@ -450,6 +450,8 @@ static void open_dumpfile(vpiHandle callh) (int)vpi_get(vpiLineNo, callh)); vpi_printf("Unable to open %s for output.\n", dump_path); vpi_control(vpiFinish, 1); + free(dump_path); + dump_path = 0; return; } else { int prec = vpi_get(vpiTimePrecision, 0); diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index 8babb0382..bf211019a 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2015 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 @@ -503,6 +503,8 @@ static void open_dumpfile(vpiHandle callh) (int)vpi_get(vpiLineNo, callh)); vpi_printf("Unable to open %s for output.\n", dump_path); vpi_control(vpiFinish, 1); + free(dump_path); + dump_path = 0; return; } else { int prec = vpi_get(vpiTimePrecision, 0); diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index 2a055da5d..30d783f90 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2015 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 @@ -410,6 +410,8 @@ static void open_dumpfile(vpiHandle callh) (int)vpi_get(vpiLineNo, callh)); vpi_printf("Unable to open %s for output.\n", dump_path); vpi_control(vpiFinish, 1); + free(dump_path); + dump_path = 0; return; } else { int prec = vpi_get(vpiTimePrecision, 0);