Commit 5c6c5073 authored by Sylvain Berfini's avatar Sylvain Berfini
Browse files

Fix crash when entry in linphonerc is empty + don't convert commented entries

parent eb9886df
......@@ -93,12 +93,18 @@ static void lpc2xml_genericxml_warning(void *ctx, const char *fmt, ...) {
*/
static int processEntry(const char *section, const char *entry, xmlNode *node, lpc2xml_context *ctx) {
const char *comment = "#";
if (strncmp(comment, entry, strlen(comment)) == 0) {
lpc2xml_log(ctx, LPC2XML_WARNING, "Skipped commented entry %s", entry);
return 0;
}
const char *content = lp_config_get_string(ctx->lpc, section, entry, NULL);
if(content == NULL) {
lpc2xml_log(ctx->ctx, LPC2XML_ERROR, "Issue when reading the lpc");
if (content == NULL) {
lpc2xml_log(ctx, LPC2XML_ERROR, "Issue when reading the lpc");
return -1;
}
lpc2xml_log(ctx, LPC2XML_MESSAGE, "Set %s|%s = %s", section, entry, content);
xmlNodeSetContent(node, (const xmlChar *) content);
return 0;
......
......@@ -114,15 +114,18 @@ static void dumpNodes(int level, xmlNode * a_node, xml2lpc_context *ctx) {
static void dumpNode(xmlNode *node, xml2lpc_context *ctx) {
xml2lpc_log(ctx, XML2LPC_DEBUG, "node type: %d, name: %s", node->type, node->name);
xml2lpc_log(ctx, XML2LPC_DEBUG, "node type: %d, name: %s", node->type, node->name);
}
static void dumpAttr(xmlNode *node, xml2lpc_context *ctx) {
xml2lpc_log(ctx, XML2LPC_DEBUG, "attr name: %s value:%s", node->name, node->children->content);
xml2lpc_log(ctx, XML2LPC_DEBUG, "attr name: %s value:%s", node->name, node->children->content);
}
static void dumpContent(xmlNode *node, xml2lpc_context *ctx) {
xml2lpc_log(ctx, XML2LPC_DEBUG, "content: %s", node->children->content);
if (node->children)
xml2lpc_log(ctx, XML2LPC_DEBUG, "content: %s", node->children->content);
else
xml2lpc_log(ctx, XML2LPC_DEBUG, "content: ");
}
static int processEntry(xmlElement *element, const char *sectionName, xml2lpc_context *ctx) {
......@@ -142,8 +145,11 @@ static int processEntry(xmlElement *element, const char *sectionName, xml2lpc_co
}
}
value = (const char *)element->children->content;
dumpContent((xmlNode *)element, ctx);
if (element->children)
value = (const char *)element->children->content;
else
value = "";
if(name != NULL) {
const char *str = lp_config_get_string(ctx->lpc, sectionName, name, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment