Index: pcbway.c =================================================================== --- pcbway.c (revision 27470) +++ pcbway.c (revision 27471) @@ -119,7 +119,7 @@ if (f == NULL) { pcb_message(PCB_MSG_ERROR, "pcbway: can't open '%s' (%s) for read\n", fn, efn); free(efn); - return -1; + return NULL; } fclose(f); @@ -127,7 +127,7 @@ if (doc == NULL) { pcb_message(PCB_MSG_ERROR, "xml parsing error on file %s (%s)\n", fn, efn); free(efn); - return -1; + return NULL; } free(efn); @@ -171,14 +171,16 @@ cachedir = pcb_build_fn(&PCB->hidlib, conf_order.plugins.order.cache); path = pcb_strdup_printf("%s%cPCBWay_Api.xml", cachedir, PCB_DIR_SEPARATOR_C); doc = pcbway_xml_load(path); - - root = xmlDocGetRootElement(doc); - if (xmlStrcmp(root->name, (xmlChar *)"PCBWayAPI") == 0) { - if (pcbway_populate_dad_(&PCB->hidlib, imp, octx, root) != 0) - PCB_DAD_LABEL(octx->dlg, "xml error: invalid API xml\n"); + if (doc != NULL) { + root = xmlDocGetRootElement(doc); + if ((root != NULL) && (xmlStrcmp(root->name, (xmlChar *)"PCBWayAPI") == 0)) { + if (pcbway_populate_dad_(&PCB->hidlib, imp, octx, root) != 0) + PCB_DAD_LABEL(octx->dlg, "xml error: invalid API xml\n"); + } + else + PCB_DAD_LABEL(octx->dlg, "xml error: root is not \n"); } - else - PCB_DAD_LABEL(octx->dlg, "xml error: root is not \n"); + PCB_DAD_LABEL(octx->dlg, "xml error: failed to parse the xml\n"); xmlFreeDoc(doc); free(cachedir);