diff --git a/Attrib.h b/Attrib.h index 67e65372b..63691ecc5 100644 --- a/Attrib.h +++ b/Attrib.h @@ -1,7 +1,7 @@ #ifndef __Attrib_H #define __Attrib_H /* - * Copyright (c) 2000 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2009 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 @@ -30,7 +30,7 @@ class Attrib { public: Attrib(); - ~Attrib(); + virtual ~Attrib(); const verinum&attribute(perm_string key) const; void attribute(perm_string key, const verinum&value); diff --git a/LineInfo.h b/LineInfo.h index f9b0b9dd8..f2262b568 100644 --- a/LineInfo.h +++ b/LineInfo.h @@ -1,7 +1,7 @@ #ifndef __LineInfo_H #define __LineInfo_H /* - * Copyright (c) 1999 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2009 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 @@ -36,7 +36,7 @@ using namespace std; class LineInfo { public: LineInfo(); - ~LineInfo(); + virtual ~LineInfo(); // Get a fully formatted file/lineno string get_fileline() const; diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index 62c6cfd1f..15c413661 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -1,7 +1,7 @@ /* * VHDL code generation for expressions. * - * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2009 Nick Gasson (nick@nickg.me.uk) * * 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 @@ -107,8 +107,10 @@ static vhdl_var_ref *translate_signal(ivl_expr_t e) if (ivl_signal_array_count(sig) > 0 && (off = ivl_expr_oper1(e))) { // Select from an array vhdl_expr *vhd_off = translate_expr(off); - if (NULL == vhd_off) + if (NULL == vhd_off) { + delete ref; return NULL; + } vhdl_type integer(VHDL_TYPE_INTEGER); ref->set_slice(vhd_off->cast(&integer)); diff --git a/tgt-vhdl/lpm.cc b/tgt-vhdl/lpm.cc index fcf631859..adde5b487 100644 --- a/tgt-vhdl/lpm.cc +++ b/tgt-vhdl/lpm.cc @@ -1,7 +1,7 @@ /* * VHDL code generation for LPM devices. * - * Copyright (C) 2008 Nick Gasson (nick@nickg.me.uk) + * Copyright (C) 2008-2009 Nick Gasson (nick@nickg.me.uk) * * 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 @@ -50,8 +50,10 @@ static vhdl_expr *concat_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm) for (int i = ivl_lpm_selects(lpm) - 1; i >= 0; i--) { vhdl_expr *e = readable_ref(scope, ivl_lpm_data(lpm, i)); - if (NULL == e) + if (NULL == e) { + delete expr; return NULL; + } expr->add_expr(e); } @@ -68,8 +70,10 @@ static vhdl_expr *binop_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop for (int i = 0; i < 2; i++) { vhdl_expr *e = readable_ref(scope, ivl_lpm_data(lpm, i)); - if (NULL == e) + if (NULL == e) { + delete expr; return NULL; + } expr->add_expr(e->cast(result_type)); } @@ -95,8 +99,10 @@ static vhdl_expr *rel_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop_t for (int i = 0; i < 2; i++) { vhdl_expr *e = readable_ref(scope, ivl_lpm_data(lpm, i)); - if (NULL == e) + if (NULL == e) { + delete expr; return NULL; + } expr->add_expr(e); } @@ -135,8 +141,10 @@ static vhdl_expr *ufunc_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm) for (unsigned i = 0; i < ivl_lpm_size(lpm); i++) { vhdl_var_ref *ref = readable_ref(scope, ivl_lpm_data(lpm, i)); - if (NULL == ref) + if (NULL == ref) { + delete fcall; return NULL; + } fcall->add_expr(ref); } @@ -195,8 +203,10 @@ static vhdl_expr *array_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm) vhdl_type *atype = new vhdl_type(*adecl->get_type()); vhdl_expr *select = readable_ref(scope, ivl_lpm_select(lpm)); - if (NULL == select) + if (NULL == select) { + delete atype; return NULL; + } vhdl_var_ref *ref = new vhdl_var_ref(renamed, atype); vhdl_type integer(VHDL_TYPE_INTEGER); diff --git a/tgt-vhdl/stmt.cc b/tgt-vhdl/stmt.cc index ec0cec8b9..d5f94c1e5 100644 --- a/tgt-vhdl/stmt.cc +++ b/tgt-vhdl/stmt.cc @@ -313,11 +313,11 @@ void make_assignment(vhdl_procedural *proc, stmt_container *container, if (NULL == test) return; - vhdl_if_stmt *vhdif = new vhdl_if_stmt(test); - if (!check_valid_assignment(decl->assignment_type(), proc, stmt)) return; + vhdl_if_stmt *vhdif = new vhdl_if_stmt(test); + // True part { vhdl_abstract_assign_stmt *a = @@ -1342,6 +1342,7 @@ int draw_casezx(vhdl_procedural *proc, stmt_container *container, "expression labels can be translated to VHDL", ivl_stmt_file(stmt), ivl_stmt_lineno(stmt), (is_casez ? "z" : "x")); + delete all; return 1; } diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index f65331f7b..f15552d6f 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -153,10 +153,13 @@ static PLI_INT32 sys_fopen_calltf(PLI_BYTE8*name) } fname = get_filename(callh, name, fileh); - if (fname == 0 && mode) free(mode_string); /* If either the mode or file name are not valid just return. */ - if (fail || fname == 0) return 0; + if (fail || fname == 0) { + free(fname); + if (mode) free(mode_string); + return 0; + } val.format = vpiIntVal; if (mode) { diff --git a/vpi/v2005_math.c b/vpi/v2005_math.c index 942c3369c..feda0818c 100644 --- a/vpi/v2005_math.c +++ b/vpi/v2005_math.c @@ -184,6 +184,7 @@ static PLI_INT32 va_single_argument_compiletf(PLI_BYTE8 *ud) /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires one argument.\n", name); + free(fun_data); return 0; } @@ -265,6 +266,7 @@ static PLI_INT32 va_double_argument_compiletf(PLI_BYTE8 *ud) /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires two arguments.\n", name); + free(fun_data); return 0; } diff --git a/vpi/va_math.c b/vpi/va_math.c index 91523de7a..cc2581422 100644 --- a/vpi/va_math.c +++ b/vpi/va_math.c @@ -216,6 +216,7 @@ static PLI_INT32 va_single_argument_compiletf(PLI_BYTE8 *ud) /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires one argument.\n", name); + free(fun_data); return 0; } @@ -303,6 +304,7 @@ static PLI_INT32 va_double_argument_compiletf(PLI_BYTE8 *ud) /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires two arguments.\n", name); + free(fun_data); return 0; }