From 439ec389a015fa0678fefd835336851956d0437a Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 18 Jan 1993 15:10:01 +0000 Subject: [PATCH] found some small leaks with Purify --- lang/cem/cemcom.ansi/arith.c | 7 ------- lang/cem/cemcom.ansi/ch3bin.c | 17 ++++++++++++++--- lang/cem/cemcom.ansi/domacro.c | 2 ++ lang/cem/cemcom.ansi/input.c | 3 +++ lang/cem/cemcom.ansi/options.c | 3 ++- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 9ade7d5d9..9190c081c 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -381,13 +381,6 @@ int2float(expp, tp) int uns = exp->ex_type->tp_unsigned; if (is_cp_cst(exp)) { - *expp = new_expr(); - **expp = *exp; - /* sprint(buf+1, "%ld", (long)(exp->VL_VALUE)); - /* buf[0] = '-'; - */ - exp = *expp; /* ??? */ - exp->ex_type = tp; exp->ex_class = Float; flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH), uns); diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index 6779f1559..0d0a01c20 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -203,8 +203,9 @@ ch3bin(expp, oper, expr) where o1 == (*expp)->VL_VALUE; and ((oper == AND) || (oper == OR)) */ - if ((oper == AND) == (ex->VL_VALUE != (arith)0)) + if ((oper == AND) == (ex->VL_VALUE != (arith)0)) { *expp = expr; + } else { ex->ex_flags |= expr->ex_flags; free_expression(expr); @@ -260,8 +261,17 @@ ch3bin(expp, oper, expr) #ifdef LINT hwarning("condition in ?: expression is constant"); #endif /* LINT */ - *expp = (*expp)->VL_VALUE ? - expr->OP_LEFT : expr->OP_RIGHT; + if ((*expp)->VL_VALUE) { + free_expression(*expp); + free_expression(expr->OP_RIGHT); + *expp = expr->OP_LEFT; + } + else { + free_expression(*expp); + free_expression(expr->OP_LEFT); + *expp = expr->OP_RIGHT; + } + free_expr(expr); (*expp)->ex_flags |= EX_ILVALUE; } else { @@ -274,6 +284,7 @@ ch3bin(expp, oper, expr) #ifdef LINT hwarning("constant expression ignored"); #endif /* LINT */ + free_expression(*expp); *expp = expr; } else { diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index de6768f56..6a5f0b57c 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -315,6 +315,7 @@ do_include() if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){ lexerror("cannot open include file \"%s\"", filenm); add_dependency(filenm); + free(filenm); } else { add_dependency(result); @@ -329,6 +330,7 @@ do_include() C_ms_std(FileName, N_BINCL, 0); } #endif /* DBSYMTAB */ + if (result != filenm) free(filenm); } } } diff --git a/lang/cem/cemcom.ansi/input.c b/lang/cem/cemcom.ansi/input.c index b6e9a4448..d45909608 100644 --- a/lang/cem/cemcom.ansi/input.c +++ b/lang/cem/cemcom.ansi/input.c @@ -63,6 +63,7 @@ AtEoIT() return 0; } +extern char *source; AtEoIF() { @@ -80,5 +81,7 @@ AtEoIF() IncludeLevel--; #endif #endif /* NOPP */ + if (WorkingDir[0] != '\0') free(WorkingDir); + if (FileName != source) free(FileName); return 0; } diff --git a/lang/cem/cemcom.ansi/options.c b/lang/cem/cemcom.ansi/options.c index 45852185b..bbb9318f2 100644 --- a/lang/cem/cemcom.ansi/options.c +++ b/lang/cem/cemcom.ansi/options.c @@ -155,7 +155,7 @@ next_option: /* to allow combined one-char options */ int i; register char *new = text; - if (++inc_total > inc_max) { + if (inc_total >= inc_max) { inctable = (char **) Realloc((char *)inctable, (unsigned)((inc_max+=10)*sizeof(char *))); @@ -167,6 +167,7 @@ next_option: /* to allow combined one-char options */ inctable[i] = new; new = tmp; } + inc_total++; } else inctable[inc_pos] = 0; break;