From 0c3cbd5410ca1efdc87cfad2944c45c80469ced2 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Fri, 4 Jun 2010 20:16:43 +0000 Subject: [PATCH] bug report 3008000 --- ChangeLog | 5 +++++ src/frontend/inpcom.c | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67efe16d2..dd7a2a450 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-06-04 Holger Vogt + * inpcom.c: bug report 3008000, overflow of fixed array of + used_subckt_names, used_model_names in fcn comment_out_unused_subckt_models + removed by dynamic memory allocation + 2010-06-03 Holger Vogt * src\spicelib\devices\bsim3soi b4soi.c b4soiacld.c b4soiask.c b4soicheck.c b4soicvtest.c diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c index 55d9d7ccc..b040fcdfd 100644 --- a/src/frontend/inpcom.c +++ b/src/frontend/inpcom.c @@ -726,13 +726,17 @@ model_bin_match( char* token, char* model_name ) also comment out .param lines with no parameters defined */ static void -comment_out_unused_subckt_models( struct line *start_card ) +comment_out_unused_subckt_models( struct line *start_card , int no_of_lines) { struct line *card; - char *used_subckt_names[1000], *used_model_names[1000], *line = NULL, *subckt_name, *model_name; + char **used_subckt_names, **used_model_names, *line = NULL, *subckt_name, *model_name; int num_used_subckt_names = 0, num_used_model_names = 0, i = 0, num_terminals = 0, tmp_cnt = 0; bool processing_subckt = FALSE, found_subckt = FALSE, remove_subckt = FALSE, found_model = FALSE, has_models = FALSE; + /* generate arrays of *char for subckt or model names */ + used_subckt_names = (char**)tmalloc(no_of_lines); + used_model_names = (char**)tmalloc(no_of_lines); + for ( card = start_card; card != NULL; card = card->li_next ) { if ( ciprefix( ".model", card->li_line ) ) has_models = TRUE; if ( ciprefix( ".cmodel", card->li_line ) ) has_models = TRUE; @@ -833,6 +837,8 @@ comment_out_unused_subckt_models( struct line *start_card ) } for ( i = 0; i < num_used_subckt_names; i++ ) tfree(used_subckt_names[i]); for ( i = 0; i < num_used_model_names; i++ ) tfree(used_model_names[i]); + tfree(used_subckt_names); + tfree(used_model_names); } @@ -1537,7 +1543,7 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name) inp_remove_excess_ws(working); if ( call_depth == 0 ) { - comment_out_unused_subckt_models(working); + comment_out_unused_subckt_models(working, line_number); line_number = inp_split_multi_param_lines(working, line_number);