Author: ivan
Date: Mon Oct 17 08:07:30 2016
New Revision: 1765219

URL: http://svn.apache.org/viewvc?rev=1765219&view=rev
Log:
Fix potential error leak in svn_xml_parser_t wrapper for XML parser discovered
by xml-test.exe#4 test added in r1765214.

* subversion/libsvn_subr/xml.c
  (svn_xml_parse): Prefer API user error provided from callback via
   svn_xml_signal_bailout(), instead of syntax XML error from Expat if we have
   both.

Modified:
    subversion/trunk/subversion/libsvn_subr/xml.c

Modified: subversion/trunk/subversion/libsvn_subr/xml.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/xml.c?rev=1765219&r1=1765218&r2=1765219&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/xml.c (original)
+++ subversion/trunk/subversion/libsvn_subr/xml.c Mon Oct 17 08:07:30 2016
@@ -428,6 +428,14 @@ svn_xml_parse(svn_xml_parser_t *svn_pars
   /* Parse some xml data */
   success = XML_Parse(svn_parser->parser, buf, (int) len, is_final);
 
+  /* Did an error occur somewhere *inside* the expat callbacks? */
+  if (svn_parser->error)
+    {
+      /* Kill all parsers and return the error */
+      svn_xml_free_parser(svn_parser);
+      return svn_parser->error;
+    }
+
   /* If expat choked internally, return its error. */
   if (! success)
     {
@@ -443,14 +451,6 @@ svn_xml_parse(svn_xml_parser_t *svn_pars
       svn_xml_free_parser(svn_parser);
       return err;
     }
-
-  /* Did an error occur somewhere *inside* the expat callbacks? */
-  if (svn_parser->error)
-    {
-      err = svn_parser->error;
-      svn_xml_free_parser(svn_parser);
-      return err;
-    }
 
   return SVN_NO_ERROR;
 }


Reply via email to