[xml] Omitting prefix in XPATH (libxml2) leads to segmentation fault



I installed C libxml2 version 2.9.4 library on my Mac (Darwin <hostname> 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64) using the standard `./configure ; make ; make install` trifecta of commands. On trying to run the `testXPath` command with the `-tree` option on an XPATH without a prefix, I get a segmentation fault.

 

    ~/home/libxml2-2.7.2 $ ./testXPath -tree "/abcde"

    In testXPath function...

    Compiled _expression_ : 0 elements 

      END

        END

          END

            END

              END

                END

                  END

                    END

                      END

                        END

                          END

                            END

                              END

                                END

                                  END

                                    END

                                      END

                                        END

                                          END

                                            END

                                              END

                                                END

                                                  END

                                                    END

                                                      END

                                                      END

                                                      END

                                                      END

                                                      END

                                                      END

                                                      END

    ...etc until:

    Segmentation fault: 11

 

 

I dug in a bit into the `testXPath.c` code, and the compilation of the XPATH seems to be faulty.

 

    comp = xmlXPathCompile(BAD_CAST str);

 

The `xmlXPathCompExprPtr` returned has its `last` member set to be `-1` if I don't supply a prefix. This causes the call to `xmlXPathDebugDumpCompExpr()` to glitch out.

 

Having a prefix in the xpath doesn't cause the fault. Am I doing something wrong?

 

Thanks,

Shivan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]