Fix a memory leak when the dump file cannot be opened

This commit is contained in:
Cary R
2015-01-08 16:14:08 -08:00
parent c57e68292c
commit 9c75a4b96b
4 changed files with 12 additions and 4 deletions
+3 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2014 Stephen Williams ([email protected]) * Copyright (c) 1999-2015 Stephen Williams ([email protected])
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * 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)); (int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path); vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1); vpi_control(vpiFinish, 1);
free(dump_path);
dump_path = 0;
return; return;
} else { } else {
int prec = vpi_get(vpiTimePrecision, 0); int prec = vpi_get(vpiTimePrecision, 0);
+3 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2002-2014 Stephen Williams ([email protected]) * Copyright (c) 2002-2015 Stephen Williams ([email protected])
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * 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)); (int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path); vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1); vpi_control(vpiFinish, 1);
free(dump_path);
dump_path = 0;
return; return;
} else { } else {
int prec = vpi_get(vpiTimePrecision, 0); int prec = vpi_get(vpiTimePrecision, 0);
+3 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003-2014 Stephen Williams ([email protected]) * Copyright (c) 2003-2015 Stephen Williams ([email protected])
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * 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)); (int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path); vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1); vpi_control(vpiFinish, 1);
free(dump_path);
dump_path = 0;
return; return;
} else { } else {
int prec = vpi_get(vpiTimePrecision, 0); int prec = vpi_get(vpiTimePrecision, 0);
+3 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999-2014 Stephen Williams ([email protected]) * Copyright (c) 1999-2015 Stephen Williams ([email protected])
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * 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)); (int)vpi_get(vpiLineNo, callh));
vpi_printf("Unable to open %s for output.\n", dump_path); vpi_printf("Unable to open %s for output.\n", dump_path);
vpi_control(vpiFinish, 1); vpi_control(vpiFinish, 1);
free(dump_path);
dump_path = 0;
return; return;
} else { } else {
int prec = vpi_get(vpiTimePrecision, 0); int prec = vpi_get(vpiTimePrecision, 0);