Skip to content

Commit 999d820

Browse files
committed
Merge commit '83fce0a3f9ef22c90a980b03bb90cbd364d5c9ab'
2 parents 19b4bae + 83fce0a commit 999d820

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
NEWS file for libxml2
22

3+
v2.12.8: Jun 12 2024
4+
5+
### Regressions
6+
7+
- parser: Fix performance regression when parsing namespaces
8+
9+
310
v2.12.7: May 13 2024
411

512
### Security

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AC_PREREQ([2.63])
33

44
m4_define([MAJOR_VERSION], 2)
55
m4_define([MINOR_VERSION], 12)
6-
m4_define([MICRO_VERSION], 7)
6+
m4_define([MICRO_VERSION], 8)
77

88
AC_INIT([libxml2],[MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION])
99
AC_CONFIG_SRCDIR([entities.c])

parser.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ xmlParserNsStartElement(xmlParserNsData *nsdb) {
14891489
static int
14901490
xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
14911491
xmlParserNsBucket **bucketPtr) {
1492-
xmlParserNsBucket *bucket;
1492+
xmlParserNsBucket *bucket, *tombstone;
14931493
unsigned index, hashValue;
14941494

14951495
if (prefix->name == NULL)
@@ -1501,10 +1501,13 @@ xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
15011501
hashValue = prefix->hashValue;
15021502
index = hashValue & (ctxt->nsdb->hashSize - 1);
15031503
bucket = &ctxt->nsdb->hash[index];
1504+
tombstone = NULL;
15041505

15051506
while (bucket->hashValue) {
1506-
if ((bucket->hashValue == hashValue) &&
1507-
(bucket->index != INT_MAX)) {
1507+
if (bucket->index == INT_MAX) {
1508+
if (tombstone == NULL)
1509+
tombstone = bucket;
1510+
} else if (bucket->hashValue == hashValue) {
15081511
if (ctxt->nsTab[bucket->index * 2] == prefix->name) {
15091512
if (bucketPtr != NULL)
15101513
*bucketPtr = bucket;
@@ -1521,7 +1524,7 @@ xmlParserNsLookup(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
15211524
}
15221525

15231526
if (bucketPtr != NULL)
1524-
*bucketPtr = bucket;
1527+
*bucketPtr = tombstone ? tombstone : bucket;
15251528
return(INT_MAX);
15261529
}
15271530

@@ -1758,7 +1761,7 @@ xmlParserNsPush(xmlParserCtxtPtr ctxt, const xmlHashedString *prefix,
17581761
unsigned hv = ctxt->nsdb->hash[i].hashValue;
17591762
unsigned newIndex;
17601763

1761-
if (hv == 0)
1764+
if ((hv == 0) || (ctxt->nsdb->hash[i].index == INT_MAX))
17621765
continue;
17631766
newIndex = hv & (newSize - 1);
17641767

0 commit comments

Comments
 (0)