Menu

#28 Empty XML file causing segmentation fault

v4.3.4
closed-fixed
1
2020-02-04
2020-01-29
No

Hi Matthieu,
in the this code , the segmentation fault error occurred in this line : node = XMLDoc_root(&doc);

if (!XMLDoc_parse_file_DOM(C2SX(xmlPath), &doc)) {
        trace_error("Error while loading XML File : %s\n",xmlPath);
        return;
}
node = XMLDoc_root(&doc);

I fixed this bug by checking the root node

if(doc.i_root==-1){
    trace_error("XML document is empty: %s\n",xmlPath);
}
node = XMLDoc_root(&doc);

thanks to check empty file in the function XMLDoc_parse_file_DOM

Discussion

  • Matthieu Labas

    Matthieu Labas - 2020-01-31

    Hi ElOualid,
    Thank you for the report. However I can't find such reference in the code.
    Can you tell me which version you're using and which file and line number you got the error?
    Thanks!
    Matthieu

     
    • SATOUR ELOualid

      SATOUR ELOualid - 2020-02-04

      Hi Matthieu,
      Excuse me for delayed reply
      I am using the VERSION "4.3.3"
      The error appeared in the line node = XMLDoc_root(&doc); this error caused by reading empty xml file

       
      • Matthieu Labas

        Matthieu Labas - 2020-02-04

        OK thanks. I changed the macro to check for the i_root validity and retur NULL if < 0.
        I pushed the changes to v4.3.4.

         
  • Matthieu Labas

    Matthieu Labas - 2020-01-31
    • labels: XMLDoc_root, XMLDoc_parse_file_DOM, segmentation fault, empty xml file --> segmentation fault, empty xml file
     
  • Matthieu Labas

    Matthieu Labas - 2020-02-04
    • status: open --> closed-fixed
    • Group: v4.3 --> v4.3.4
     

Log in to post a comment.

MongoDB Logo MongoDB