|
|
74177a |
From 4fefc3908ce527de4ca3d7386886c2447d6b4c14 Mon Sep 17 00:00:00 2001
|
|
|
74177a |
From: David Rheinsberg <david.rheinsberg@gmail.com>
|
|
|
74177a |
Date: Tue, 19 Apr 2022 13:29:53 +0200
|
|
|
74177a |
Subject: [PATCH] launch/config: keep empty cdata around
|
|
|
74177a |
|
|
|
74177a |
We expect the `node->cdata` pointer to contain the actual content of an
|
|
|
74177a |
XML entry. Make sure it is initialized to an empty string, so we can
|
|
|
74177a |
dereference it without checking for validity everywhere.
|
|
|
74177a |
|
|
|
74177a |
Note that we want it to be an owned string, to allow claiming the value.
|
|
|
74177a |
We will avoid any `n_cdata + 'static ""` here, to keep the code simple.
|
|
|
74177a |
The performance of that strdup() merely affects XML parsing, no bus
|
|
|
74177a |
runtime.
|
|
|
74177a |
|
|
|
74177a |
Reported-by: Steffen Robertz
|
|
|
74177a |
Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
|
|
|
74177a |
---
|
|
|
74177a |
src/launch/config.c | 4 ++++
|
|
|
74177a |
1 file changed, 4 insertions(+)
|
|
|
74177a |
|
|
|
74177a |
diff --git a/src/launch/config.c b/src/launch/config.c
|
|
|
74177a |
index 490d7b7d..cb7e3fae 100644
|
|
|
74177a |
--- a/src/launch/config.c
|
|
|
74177a |
+++ b/src/launch/config.c
|
|
|
74177a |
@@ -133,6 +133,10 @@ int config_node_new(ConfigNode **nodep, ConfigNode *parent, unsigned int type) {
|
|
|
74177a |
break;
|
|
|
74177a |
}
|
|
|
74177a |
|
|
|
74177a |
+ node->cdata = strdup("");
|
|
|
74177a |
+ if (!node->cdata)
|
|
|
74177a |
+ return error_origin(-ENOMEM);
|
|
|
74177a |
+
|
|
|
74177a |
*nodep = node;
|
|
|
74177a |
node = NULL;
|
|
|
74177a |
return 0;
|