From 6952d444ae657e58821dfc0ec584b1399ab754e1 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 11 Aug 2021 02:48:36 +0200 Subject: [PATCH] Upstream an Apple patch to array.c This upstreams the patch 'src__cmd__ksh93__sh__array.c.diff' from Apple's ksh 93u+ distribution in ksh-28.tar.gz: https://opensource.apple.com/tarballs/ksh/ src/cmd/ksh93/sh/array.c: array_putval(), nv_associative(): - Zero two table pointers after closing/freeing the tables with libast's dtclose(). No information is available from Apple as to what specific problems this fixes, but at worst this is harmless. --- src/cmd/ksh93/sh/array.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/ksh93/sh/array.c b/src/cmd/ksh93/sh/array.c index e3d081394..01b15560c 100644 --- a/src/cmd/ksh93/sh/array.c +++ b/src/cmd/ksh93/sh/array.c @@ -681,7 +681,10 @@ static void array_putval(Namval_t *np, const char *string, int flags, Namfun_t * if(is_associative(ap)) (*ap->fun)(np, NIL(char*), NV_AFREE); else if(ap->table) + { dtclose(ap->table); + ap->table = 0; + } nv_offattr(np,NV_ARRAY); } if(!mp || mp!=np || is_associative(ap)) @@ -1702,6 +1705,7 @@ void *nv_associative(register Namval_t *np,const char *sp,int mode) if((ap->header.nelem&ARRAY_MASK)==0 && (ap->cur=nv_search("0",ap->header.table,0))) nv_associative(np,(char*)0,NV_ADELETE); dtclose(ap->header.table); + ap->header.table = 0; } return((void*)ap); case NV_ANEXT: