From c5a722ccd498ac24b560f9cbe4e73e6a25aaa33e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 27 Sep 2022 16:28:44 +0000 Subject: [PATCH] writer: Add an empty string to the stringpool This is useful when we have some offset that isn't initialised. It will point to the start of the string pool which is some random string that happened to be added first. An empty string at least signifies better that something is unset. Signed-off-by: Michael Tremer --- src/writer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/writer.c b/src/writer.c index 51e9a8e..b52f74f 100644 --- a/src/writer.c +++ b/src/writer.c @@ -102,6 +102,13 @@ LOC_EXPORT int loc_writer_new(struct loc_ctx* ctx, struct loc_writer** writer, return r; } + // Add an empty string to the stringpool + r = loc_stringpool_add(w->pool, ""); + if (r) { + loc_writer_unref(w); + return r; + } + // Initialize the network tree r = loc_network_tree_new(ctx, &w->networks); if (r) { -- 2.39.2