libdpkg: Make varbuf_detach() always return a string
commit17dd898818b423c1ec1c2f1b80de4eda4a727012
authorGuillem Jover <guillem@debian.org>
Fri, 17 May 2024 21:35:26 +0000 (17 23:35 +0200)
committerGuillem Jover <guillem@debian.org>
Sun, 19 May 2024 20:51:33 +0000 (19 22:51 +0200)
tree170e53912507097f6095f5ecd2a2162dfb126724
parent0e589d3fcd3e94b70dd37d73fc21121ed2035609
libdpkg: Make varbuf_detach() always return a string

When we have added no content into a varbuf, we avoid allocating
memory, but when calling varbuf_detach() the caller expects a valid
string no matter what, and having to care about it returning NULL
is error-prone. Instead, when we have no buffer, we return an allocated
empty string.
lib/dpkg/t/t-varbuf.c
lib/dpkg/varbuf.c