diff options
author | Alan Modra <amodra@gmail.com> | 2025-01-22 07:39:53 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2025-01-23 11:40:40 +1030 |
commit | a62e0f8597b13b48c16a889a3afb993bfce75f24 (patch) | |
tree | 710a1d761a30adddcf420d063757d9d4087c2a29 | |
parent | 63488ec7b8b4fa720ea5ee157fe5cd1aedbe153a (diff) | |
download | binutils-a62e0f8597b13b48c16a889a3afb993bfce75f24.zip binutils-a62e0f8597b13b48c16a889a3afb993bfce75f24.tar.gz binutils-a62e0f8597b13b48c16a889a3afb993bfce75f24.tar.bz2 |
Another ldelf_before_allocation leak
This fixes an even more obvious leak.
* ldelf.c (ldelf_before_allocation): Free copied elf_dt_audit.
Simplify loop.
-rw-r--r-- | ld/ldelf.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -1821,24 +1821,22 @@ ldelf_before_allocation (char **audit, char **depaudit, a dep audit entry. */ if (audit_libs && *audit_libs != '\0') { - char *cp = xstrdup (audit_libs); + char *copy_audit_libs = xstrdup (audit_libs); + char *cp = copy_audit_libs; do { - int more = 0; char *cp2 = strchr (cp, config.rpath_separator); if (cp2) - { - *cp2 = '\0'; - more = 1; - } + *cp2++ = '\0'; - if (cp != NULL && *cp != '\0') + if (*cp != '\0') ldelf_append_to_separated_string (depaudit, cp); - cp = more ? ++cp2 : NULL; + cp = cp2; } while (cp != NULL); + free (copy_audit_libs); } } |