stdlib: Simplify buffer management in canonicalize
commitef0700004bf0dccf493a5e8e21f71d9e7972ea9f
authorFlorian Weimer <fweimer@redhat.com>
Tue, 5 Jul 2022 09:04:45 +0000 (5 11:04 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 5 Jul 2022 09:04:45 +0000 (5 11:04 +0200)
treec96014f75b7bb4cda222d7ee6ed0fbd22d467c89
parent9d77023bf33ca5d0b07c318fe9fbe4347f0ae25a
stdlib: Simplify buffer management in canonicalize

Move the buffer management from realpath_stk to __realpath.  This
allows returning directly after allocation errors.

Always make a copy of the result buffer using strdup even if it is
already heap-allocated.  (Heap-allocated buffers are somewhat rare.)
This avoids GCC warnings at certain optimization levels.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
stdlib/canonicalize.c