Skip to content

Commit

Permalink
nv_newattr(): fix potential invalid free
Browse files Browse the repository at this point in the history
src/cmd/ksh93/sh/name.c:
- Zero the 'cp' pointer after freeing it, as the next loop
  iteration may otherwise re-use the old address.
  • Loading branch information
McDutchie committed Jan 17, 2021
1 parent 9a48ba1 commit e25d9f4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd/ksh93/sh/name.c
Expand Up @@ -3032,6 +3032,7 @@ void nv_newattr (register Namval_t *np, unsigned newatts, int size)
if(!mp)
nv_putval (np, cp, NV_RDONLY);
free(cp);
cp = 0;
}
}
while(ap && nv_nextsub(np));
Expand Down

0 comments on commit e25d9f4

Please sign in to comment.