Skip to content

Commit f785cf5

Browse files
authored
Merge branch 'zeux:master' into master
2 parents 273853d + b080173 commit f785cf5

File tree

11 files changed

+67
-32
lines changed

11 files changed

+67
-32
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
name: ${{matrix.os}} (${{matrix.compiler}}, ${{matrix.defines}})
2020
runs-on: ${{matrix.os}}-latest
2121
steps:
22-
- uses: actions/checkout@v1
22+
- uses: actions/checkout@v4
2323
- name: make test
2424
run: |
2525
export CXX=${{matrix.compiler}}
@@ -41,7 +41,7 @@ jobs:
4141
name: ${{matrix.os}} cmake
4242
runs-on: ${{matrix.os}}-latest
4343
steps:
44-
- uses: actions/checkout@v1
44+
- uses: actions/checkout@v4
4545
- name: cmake configure
4646
run: |
4747
mkdir cmake && cd cmake
@@ -57,7 +57,7 @@ jobs:
5757
arch: [Win32, x64]
5858
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
5959
steps:
60-
- uses: actions/checkout@v1
60+
- uses: actions/checkout@v4
6161
- name: cmake configure
6262
run: cmake . -DPUGIXML_BUILD_TESTS=ON -D${{matrix.defines}}=ON -A ${{matrix.arch}}
6363
- name: cmake test

.github/workflows/cifuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fuzz-seconds: 30
1818
dry-run: false
1919
- name: Upload Crash
20-
uses: actions/upload-artifact@v3
20+
uses: actions/upload-artifact@v4
2121
if: failure() && steps.build.outcome == 'success'
2222
with:
2323
name: artifacts

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,12 @@ int main()
7070
## License
7171

7272
This library is available to anybody free of charge, under the terms of MIT License (see LICENSE.md).
73+
74+
This work is based on the pugxml parser, which carried the following Public Domain dedication:
75+
76+
// Pug XML Parser - Version 1.0002
77+
// --------------------------------------------------------
78+
// Copyright (C) 2003, by Kristen Wegner ([email protected])
79+
// Released into the Public Domain. Use at your own risk.
80+
// See pugxml.xml for further information, history, etc.
81+
// Contributions by Neville Franks ([email protected]).

docs/manual.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ NOTE: In that example `PUGIXML_API` is inconsistent between several source files
251251

252252
pugixml is written in standard-compliant C{plus}{plus} with some compiler-specific workarounds where appropriate. pugixml is compatible with the C{plus}{plus}11 standard, but does not require C{plus}{plus}11 support. Each version is tested with a unit test suite with code coverage exceeding 99%.
253253

254-
pugixml runs on a variety of desktop platforms (including Microsoft Windows, Linux, FreeBSD, Apple MacOSX and Sun Solaris), game consoles (inclusing Microsoft Xbox 360, Microsoft Xbox One, Nintendo Wii, Sony Playstation Portable and Sony Playstation 3) and mobile platforms (including Android, iOS, BlackBerry, Samsung bada and Microsoft Windows CE).
254+
pugixml runs on a variety of desktop platforms (including Microsoft Windows, Linux, FreeBSD, Apple MacOSX and Sun Solaris), game consoles (including Microsoft Xbox 360, Microsoft Xbox One, Nintendo Wii, Sony Playstation Portable and Sony Playstation 3) and mobile platforms (including Android, iOS, BlackBerry, Samsung bada and Microsoft Windows CE).
255255

256256
pugixml supports various architectures, such as x86/x86-64, PowerPC, ARM, MIPS and SPARC. In general it should run on any architecture since it does not use architecture-specific code and does not rely on features such as unaligned memory access.
257257

docs/manual.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ <h3 id="install.portability"><a class="anchor" href="#install.portability"></a><
10381038
<p>pugixml is written in standard-compliant C&#43;&#43; with some compiler-specific workarounds where appropriate. pugixml is compatible with the C&#43;&#43;11 standard, but does not require C&#43;&#43;11 support. Each version is tested with a unit test suite with code coverage exceeding 99%.</p>
10391039
</div>
10401040
<div class="paragraph">
1041-
<p>pugixml runs on a variety of desktop platforms (including Microsoft Windows, Linux, FreeBSD, Apple MacOSX and Sun Solaris), game consoles (inclusing Microsoft Xbox 360, Microsoft Xbox One, Nintendo Wii, Sony Playstation Portable and Sony Playstation 3) and mobile platforms (including Android, iOS, BlackBerry, Samsung bada and Microsoft Windows CE).</p>
1041+
<p>pugixml runs on a variety of desktop platforms (including Microsoft Windows, Linux, FreeBSD, Apple MacOSX and Sun Solaris), game consoles (including Microsoft Xbox 360, Microsoft Xbox One, Nintendo Wii, Sony Playstation Portable and Sony Playstation 3) and mobile platforms (including Android, iOS, BlackBerry, Samsung bada and Microsoft Windows CE).</p>
10421042
</div>
10431043
<div class="paragraph">
10441044
<p>pugixml supports various architectures, such as x86/x86-64, PowerPC, ARM, MIPS and SPARC. In general it should run on any architecture since it does not use architecture-specific code and does not rely on features such as unaligned memory access.</p>

src/pugiconfig.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/**
22
* pugixml parser - version 1.15
33
* --------------------------------------------------------
4-
* Copyright (C) 2006-2025, by Arseny Kapoulkine ([email protected])
54
* Report bugs and download new versions at https://pugixml.org/
65
*
7-
* This library is distributed under the MIT License. See notice at the end
8-
* of this file.
6+
* SPDX-FileCopyrightText: Copyright (C) 2006-2025, by Arseny Kapoulkine ([email protected])
7+
* SPDX-License-Identifier: MIT
98
*
10-
* This work is based on the pugxml parser, which is:
11-
* Copyright (C) 2003, by Kristen Wegner ([email protected])
9+
* See LICENSE.md or notice at the end of this file.
1210
*/
1311

1412
#ifndef HEADER_PUGICONFIG_HPP

src/pugixml.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/**
22
* pugixml parser - version 1.15
33
* --------------------------------------------------------
4-
* Copyright (C) 2006-2025, by Arseny Kapoulkine ([email protected])
54
* Report bugs and download new versions at https://pugixml.org/
65
*
7-
* This library is distributed under the MIT License. See notice at the end
8-
* of this file.
6+
* SPDX-FileCopyrightText: Copyright (C) 2006-2025, by Arseny Kapoulkine ([email protected])
7+
* SPDX-License-Identifier: MIT
98
*
10-
* This work is based on the pugxml parser, which is:
11-
* Copyright (C) 2003, by Kristen Wegner ([email protected])
9+
* See LICENSE.md or notice at the end of this file.
1210
*/
1311

1412
#ifndef SOURCE_PUGIXML_CPP
@@ -264,7 +262,7 @@ PUGI_IMPL_NS_BEGIN
264262

265263
while (srclen && *dst && *src == *dst)
266264
{
267-
--srclen; ++dst; ++src;
265+
--srclen; ++dst; ++src;
268266
}
269267
return srclen == 0 && *dst == 0;
270268
}
@@ -4780,11 +4778,13 @@ PUGI_IMPL_NS_BEGIN
47804778
// if convert_buffer below throws bad_alloc, we still need to deallocate contents if we own it
47814779
auto_deleter<void> contents_guard(own ? contents : NULL, xml_memory::deallocate);
47824780

4781+
// early-out for empty documents to avoid buffer allocation overhead
4782+
if (size == 0) return make_parse_result((options & parse_fragment) ? status_ok : status_no_document_element);
4783+
47834784
// get private buffer
47844785
char_t* buffer = NULL;
47854786
size_t length = 0;
47864787

4787-
// coverity[var_deref_model]
47884788
if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory);
47894789

47904790
// after this we either deallocate contents (below) or hold on to it via doc->buffer, so we don't need to guard it
@@ -9516,10 +9516,10 @@ PUGI_IMPL_NS_BEGIN
95169516
size_t hash_size = 1;
95179517
while (hash_size < size_ + size_ / 2) hash_size *= 2;
95189518

9519-
const void** hash_data = static_cast<const void**>(alloc->allocate(hash_size * sizeof(void**)));
9519+
const void** hash_data = static_cast<const void**>(alloc->allocate(hash_size * sizeof(void*)));
95209520
if (!hash_data) return;
95219521

9522-
memset(hash_data, 0, hash_size * sizeof(const void**));
9522+
memset(hash_data, 0, hash_size * sizeof(void*));
95239523

95249524
xpath_node* write = _begin;
95259525

@@ -13100,8 +13100,11 @@ namespace pugi
1310013100

1310113101
// look for existing variable
1310213102
for (xpath_variable* var = _data[hash]; var; var = var->_next)
13103-
if (impl::strequal(var->name(), name))
13103+
{
13104+
const char_t* vn = var->name();
13105+
if (vn && impl::strequal(vn, name))
1310413106
return var;
13107+
}
1310513108

1310613109
return NULL;
1310713110
}
@@ -13152,8 +13155,11 @@ namespace pugi
1315213155

1315313156
// look for existing variable
1315413157
for (xpath_variable* var = _data[hash]; var; var = var->_next)
13155-
if (impl::strequal(var->name(), name))
13158+
{
13159+
const char_t* vn = var->name();
13160+
if (vn && impl::strequal(vn, name))
1315613161
return var->type() == type ? var : NULL;
13162+
}
1315713163

1315813164
// add new variable
1315913165
xpath_variable* result = impl::new_xpath_variable(type, name);

src/pugixml.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/**
22
* pugixml parser - version 1.15
33
* --------------------------------------------------------
4-
* Copyright (C) 2006-2025, by Arseny Kapoulkine ([email protected])
54
* Report bugs and download new versions at https://pugixml.org/
65
*
7-
* This library is distributed under the MIT License. See notice at the end
8-
* of this file.
6+
* SPDX-FileCopyrightText: Copyright (C) 2006-2025, by Arseny Kapoulkine ([email protected])
7+
* SPDX-License-Identifier: MIT
98
*
10-
* This work is based on the pugxml parser, which is:
11-
* Copyright (C) 2003, by Kristen Wegner ([email protected])
9+
* See LICENSE.md or notice at the end of this file.
1210
*/
1311

1412
// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons

tests/test_document.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,17 @@ TEST(document_load_string)
473473
CHECK_NODE(doc, STR("<node/>"));
474474
}
475475

476+
TEST(document_load_string_empty)
477+
{
478+
xml_document doc;
479+
480+
CHECK(doc.load_string(STR("")).status == status_no_document_element);
481+
CHECK(!doc.first_child());
482+
483+
CHECK(doc.load_string(STR(""), parse_fragment));
484+
CHECK(!doc.first_child());
485+
}
486+
476487
TEST(document_load_file)
477488
{
478489
xml_document doc;
@@ -864,6 +875,19 @@ TEST(document_load_buffer_inplace_own)
864875
CHECK_NODE(doc, STR("<node/>"));
865876
}
866877

878+
TEST(document_load_buffer_inplace_own_empty)
879+
{
880+
allocation_function alloc = get_memory_allocation_function();
881+
882+
void* text1 = alloc(1);
883+
void* text2 = alloc(1);
884+
CHECK(text1 && text2);
885+
886+
xml_document doc;
887+
CHECK(doc.load_buffer_inplace_own(text1, 0, parse_fragment));
888+
CHECK(doc.load_buffer_inplace_own(text2, 0).status == status_no_document_element);
889+
}
890+
867891
TEST(document_parse_result_bool)
868892
{
869893
xml_parse_result result;

tests/test_dom_traverse.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ struct test_walker: xml_tree_walker
896896
#endif
897897
}
898898

899-
virtual bool begin(xml_node& node) PUGIXML_OVERRIDE
899+
bool begin(xml_node& node) PUGIXML_OVERRIDE
900900
{
901901
log += STR("|");
902902
log += depthstr();
@@ -908,7 +908,7 @@ struct test_walker: xml_tree_walker
908908
return ++call_count != stop_count && xml_tree_walker::begin(node);
909909
}
910910

911-
virtual bool for_each(xml_node& node) PUGIXML_OVERRIDE
911+
bool for_each(xml_node& node) PUGIXML_OVERRIDE
912912
{
913913
log += STR("|");
914914
log += depthstr();
@@ -920,7 +920,7 @@ struct test_walker: xml_tree_walker
920920
return ++call_count != stop_count && xml_tree_walker::end(node);
921921
}
922922

923-
virtual bool end(xml_node& node) PUGIXML_OVERRIDE
923+
bool end(xml_node& node) PUGIXML_OVERRIDE
924924
{
925925
log += STR("|");
926926
log += depthstr();

tests/test_write.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ struct test_writer: xml_writer
237237
{
238238
std::basic_string<char_t> contents;
239239

240-
virtual void write(const void* data, size_t size) PUGIXML_OVERRIDE
240+
void write(const void* data, size_t size) PUGIXML_OVERRIDE
241241
{
242242
CHECK(size % sizeof(char_t) == 0);
243243
contents.append(static_cast<const char_t*>(data), size / sizeof(char_t));
@@ -687,7 +687,7 @@ TEST(write_flush_coverage)
687687
#ifndef PUGIXML_NO_EXCEPTIONS
688688
struct throwing_writer: xml_writer
689689
{
690-
virtual void write(const void*, size_t) PUGIXML_OVERRIDE
690+
void write(const void*, size_t) PUGIXML_OVERRIDE
691691
{
692692
throw std::runtime_error("write failed");
693693
}

0 commit comments

Comments
 (0)