[libxml2] Use xmlStrlen in *CtxtReadDoc



commit 5b2d07a72670513e41b481a9d922c983a64027ca
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Sat Aug 20 17:00:50 2022 +0200

    Use xmlStrlen in *CtxtReadDoc
    
    xmlStrlen handles buffers larger than INT_MAX more gracefully.

 HTMLparser.c | 7 ++-----
 parser.c     | 6 ++----
 2 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/HTMLparser.c b/HTMLparser.c
index aef82c02..975099ca 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -7116,13 +7116,10 @@ htmlDocPtr
 htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
                const char *URL, const char *encoding, int options)
 {
-    const char *buf;
-
     if (cur == NULL)
         return (NULL);
-    buf = (const char *) cur;
-    return (htmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding,
-                               options));
+    return (htmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
+                               encoding, options));
 }
 
 /**
diff --git a/parser.c b/parser.c
index c313d88a..93f031be 100644
--- a/parser.c
+++ b/parser.c
@@ -15359,12 +15359,10 @@ xmlDocPtr
 xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
                const char *URL, const char *encoding, int options)
 {
-    const char *buf;
-
     if (cur == NULL)
         return (NULL);
-    buf = (const char *) cur;
-    return (xmlCtxtReadMemory(ctxt, buf, strlen(buf), URL, encoding, options));
+    return (xmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
+                              encoding, options));
 }
 
 /**


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