From 36bec5ea384f69bbc5a116e12a4dfaa3e9728295 Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Tue, 18 Feb 1997 17:31:44 +0000 Subject: [PATCH] Do not free unallocated memory (win16) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9901 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/et/error_message.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/util/et/error_message.c b/src/util/et/error_message.c index cf55af0c4..78bca4208 100644 --- a/src/util/et/error_message.c +++ b/src/util/et/error_message.c @@ -162,15 +162,23 @@ oops: return(buffer); } + +#ifdef _MSDOS +/* + * Win16 applications cannot call malloc while the DLL is being + * initialized... To get around this, we pre-allocate an array + * sufficient to hold several error tables. + */ +#define PREALLOCATE_ETL 32 +static struct et_list etl[PREALLOCATE_ETL]; +static int etl_used = 0; +#endif + KRB5_DLLIMP errcode_t KRB5_CALLCONV add_error_table(et) const struct error_table FAR * et; { struct et_list *el = _et_list; -#ifdef _MSDOS - static struct et_list etl[32]; - static int etl_used = 0; -#endif while (el) { if (el->table->base == et->base) @@ -179,12 +187,7 @@ add_error_table(et) } #ifdef _MSDOS - /* - * Win16 applications cannot call malloc while the DLL is being - * initialized... To get around this, we pre-allocate an array - * sufficient to hold several error tables. - */ - if (etl_used < sizeof(etl)/sizeof(struct et_list)) + if (etl_used < PREALLOCATE_ETL) el = &etl[etl_used++]; else #endif @@ -211,7 +214,10 @@ remove_error_table(et) el2->next = el->next; else _et_list = el->next; - (void) free(el); +#ifdef _MSDOS + if ((el < etl) || (el > &etl[PREALLOCATE_ETL-1])) +#endif + (void) free(el); return 0; } el2 = el; -- 2.26.2