xmllite: Fix reader_cmp for multiple characters.
Vincent Povirk
madewokherd at gmail.com
Fri Feb 20 13:33:28 CST 2015
reader_get_ptr reads at least one character ahead, but reader_cmp can
be given a string with multiple characters. If we didn't read enough
characters, reader_cmp will report a non-match when it shouldn't. So
make sure we read far enough ahead to compare the string.
-------------- next part --------------
From c5e1e7624875ff935954a2a2ee21b70216bd2ab9 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Fri, 20 Feb 2015 12:54:32 -0600
Subject: [PATCH] xmllite: Fix reader_cmp for multiple characters.
---
dlls/xmllite/reader.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index cf89fb7..2aa9d95 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -900,8 +900,20 @@ static inline WCHAR *reader_get_ptr(xmlreader *reader)
static int reader_cmp(xmlreader *reader, const WCHAR *str)
{
+ int i=0;
const WCHAR *ptr = reader_get_ptr(reader);
- return strncmpW(str, ptr, strlenW(str));
+ while (str[i])
+ {
+ if (!ptr[i])
+ {
+ reader_more(reader);
+ ptr = reader_get_ptr(reader);
+ }
+ if (str[i] != ptr[i])
+ return ptr[i] - str[i];
+ i++;
+ }
+ return 0;
}
/* moves cursor n WCHARs forward */
--
2.1.0
More information about the wine-patches
mailing list