bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

declare -A +A


From: Grisha Levit
Subject: declare -A +A
Date: Wed, 7 Feb 2024 02:23:42 -0500

If a single declare command both sets and unsets the array or assoc
attribute for an existing scalar variable, the `value' member of the
SHELL_VAR is assigned an ARRAY* or HASH_TABLE* as appropriate, but
later ends up treated as a char*:

    $ bash-asan -c 'X=Y; declare -A +A X; declare -p X'
    declare -- X=$'\200_\020\005\001'

    $ bash-lsan -c 'X=Y; declare -A +A X; X=(Z)'
    ERROR: LeakSanitizer: detected memory leaks
    Direct leak of 1024 byte(s) in 1 object(s) allocated from:
        #0 0xaaaada7342f8 in malloc
        #1 0xaaaada7f24d0 in xmalloc xmalloc.c:107:10
        #2 0xaaaada7b81fc in hash_create hashlib.c:72:25
        #3 0xaaaada7cc0c8 in convert_var_to_assoc arrayfunc.c:117:10

Maybe it would be appropriate to reject a request to turn off an
attribute that is being turned on?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]