]> git.mxchange.org Git - flightgear.git/commitdiff
Fix an off by one problem.
authorehofman <ehofman>
Thu, 30 Apr 2009 13:56:50 +0000 (13:56 +0000)
committerTim Moore <timoore@redhat.com>
Fri, 1 May 2009 22:44:22 +0000 (00:44 +0200)
utils/xmlgrep/ChangeLog
utils/xmlgrep/xml.c

index be69264318c3cfec62f5fb39edad8312ae1968bf..81cd7801d6275cc1b9a0f6373bbc22370fb19d01 100644 (file)
@@ -1,3 +1,6 @@
+30-04-2009
+  * Fix an off by one problem.
+
 28-04-2009
   * changes to the code to allow walking the xml-tree using "*" as a node name
   * add printxml, an example utility that walks an xml-tree and prints it
index 8ec3e0439a53d0e68dc10ad557ccbf68e70c8300..fa379d748e6839610c3d5bf0cf50a0c3e97f547a 100644 (file)
@@ -1564,11 +1564,10 @@ __xmlNodeGet(const char *start, size_t *len, char **name, size_t *rlen, size_t *
             restlen -= new-cur;
             cur = new;
         }
-
         if (*cur != '/')                       /* cascading tag found */
         {
             char *node = "*";
-            size_t slen = restlen+1;
+            size_t slen = restlen+1; /* due to cur-1 below*/
             size_t nlen = 1;
             size_t pos = -1;
 
@@ -1593,15 +1592,17 @@ __xmlNodeGet(const char *start, size_t *len, char **name, size_t *rlen, size_t *
                     *len = XML_UNEXPECTED_EOF;
                     return 0;
                 }
-                else new = cur + slen;
-            }
 
-            restlen -= slen;
-            cur = new;
+                slen--;
+                new = cur + slen;
+                restlen -= slen;
+            }
+            else restlen -= slen;
 
             /* 
              * look for the closing tag of the cascading block
              */
+            cur = new;
             new = memchr(cur, '<', restlen);
             if (!new)
             {
@@ -1664,7 +1665,7 @@ __xmlNodeGet(const char *start, size_t *len, char **name, size_t *rlen, size_t *
             *len = XML_ELEMENT_NO_CLOSING_TAG;
             return 0;
         }
-    }
+    } /* while */
 
     if (found == 0)
     {