[libxml2] Fix undefined behavior in xmlRegExecPushStringInternal



commit 34e445674d5fe7b94b702449ac40d4c0a3ca9d12
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Wed May 31 16:48:27 2017 +0200

    Fix undefined behavior in xmlRegExecPushStringInternal
    
    It's stupid, but the behavior of memcpy(NULL, NULL, 0) is undefined.

 xmlregexp.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/xmlregexp.c b/xmlregexp.c
index ca3b4f4..7dc6eea 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -4089,8 +4089,9 @@ rollback:
                    xmlFree(exec->errString);
                exec->errString = xmlStrdup(value);
                exec->errState = exec->state;
-               memcpy(exec->errCounts, exec->counts,
-                      exec->comp->nbCounters * sizeof(int));
+                if (exec->comp->nbCounters)
+                    memcpy(exec->errCounts, exec->counts,
+                           exec->comp->nbCounters * sizeof(int));
            }
 
            /*


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