Skip to content

Commit

Permalink
V0.9: fix memory leak in VAMS $simparam$str
Browse files Browse the repository at this point in the history
  • Loading branch information
caryr committed Jul 28, 2014
1 parent c317186 commit 3a91148
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vpi/vams_simparam.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2008-2011 Cary R. (cygcary@yahoo.com)
* Copyright (C) 2008-2014 Cary R. (cygcary@yahoo.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -225,7 +225,7 @@ static PLI_INT32 simparam_str_calltf(PLI_BYTE8 *name_ext)
retval = strdup(vpi_get_str(vpiFullName,
vpi_handle(vpiScope,callh)));
} else {
if (defval == 0) {
if (defval == NULL) {
vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("$simparam%s unknown parameter name \"%s\".\n",
Expand All @@ -241,6 +241,7 @@ static PLI_INT32 simparam_str_calltf(PLI_BYTE8 *name_ext)
val.format = vpiStringVal;
val.value.str = retval;
vpi_put_value(callh, &val, 0, vpiNoDelay);
if (defval != retval) free(defval);
free(retval);

return 0;
Expand Down

0 comments on commit 3a91148

Please sign in to comment.