Fix a memory leak when the dump file cannot be opened

This commit is contained in:
Cary R 2015-01-08 16:09:55 -08:00
parent c57e68292c
commit 9c75a4b96b
4 changed files with 12 additions and 4 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);