Repository navigation
Conversation
6719499 to
08542db
Compare
A metadata element with empty content (e.g. <value></value>,
<_short></_short>) leaves node->children == NULL in libxml2, so reading
node->children->content is a null deref that segfaults wcm at startup.
The same function already guarded this for <min>/<max>/<precision>/
<hint>/<default>/<category> via 'if (!node->children) continue;', but the
guard was missing for <_short>, <_long>, <type> (dynamic-list), the
<desc> child loop, and the plugin/group-level <_short>/<_long> nodes.
Add a small helper:
static xmlChar *node_text(const xmlNode *node)
{
return (node->children) ? node->children->content : nullptr;
}
and use it at every site, with a null-check before use. The 'is it
empty?' logic now lives in one place instead of being copy-pasted.
Fixes WayfireWM#126
|
NAK. The metadata should be fixed, not consumers of the metadata. It does not make sense to have an empty |
There are already checks for empty |
|
I use wcm with all upstream metadata and it does not crash. Can you show an example of the offending metadata you are using to crash it? |
I have my own plugins that are not mainstream. |
I would accept a PR that prints a warning and exits in these cases. |
Summary
Fixes #126 — wcm segfaults at startup when a loaded plugin's metadata contains a metadata element with empty content (
<value></value>,<_short></_short>, etc.).Root cause
A metadata element with no text content leaves
node->children == NULLin libxml2, so readingnode->children->contentis a null deref → SIGSEGV.The
get_plugin_data/Optionconstructors already guarded against this for<min>,<max>,<precision>,<hint>,<default>and<category>viaif (!node->children) continue;— but the guard was missing for several other element types:Option::_short,Option::_longOption::type(dynamic-list)Option::descchild loop (<value>/<_name>, the crash from wcm segfaults at startup when a loaded plugin's metadata has an empty <value> element in an option <desc> #126)Plugin::_short,Plugin::_longGroup::_short,Subgroup::_shortChange
Add a small helper that centralises the "is it empty?" logic:
and use it at every site, with a null-check before use. The previously-guarded sites are untouched; the previously-unguarded ones now call
node_text()andcontinuewhen it returnsNULL.This is option 1 from the discussion: a DRY helper rather than a blanket top-of-loop guard (which would change semantics for
<default></default>, where an empty string is a valid distinct value).Testing
node_textsubstitutions, so it is style-clean.node->children->contentsites in the file are within an existingif (!node->children)guard.