[FarGroup/FarManager] master: tinyxml2 8224e42 (4f139c590)

1 view
Skip to first unread message

farg...@farmanager.com

unread,
Jun 20, 2026, 7:01:12 AMJun 20
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/4f139c590d87f22471cc2f03c4817db3c2f307a0

>---------------------------------------------------------------

commit 4f139c590d87f22471cc2f03c4817db3c2f307a0
Author: Alex Alabuzhev <alab...@gmail.com>
Date: Sat Jun 20 11:47:13 2026 +0100

tinyxml2 8224e42


>---------------------------------------------------------------

4f139c590d87f22471cc2f03c4817db3c2f307a0
far/thirdparty/tinyxml2/tinyxml2.cpp | 87 +++++++++++++++---------------------
far/thirdparty/tinyxml2/tinyxml2.h | 29 ++++++------
2 files changed, 50 insertions(+), 66 deletions(-)

diff --git a/far/thirdparty/tinyxml2/tinyxml2.cpp b/far/thirdparty/tinyxml2/tinyxml2.cpp
index 71858484a..6dad11423 100644
--- a/far/thirdparty/tinyxml2/tinyxml2.cpp
+++ b/far/thirdparty/tinyxml2/tinyxml2.cpp
@@ -24,7 +24,7 @@ distribution.
#include "tinyxml2.h"

#include <new> // yes, this one new style header, is in the Android SDK.
-#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__) || defined(__CC_ARM)
+#if defined(ANDROID_NDK)
# include <stddef.h>
# include <stdarg.h>
#else
@@ -40,9 +40,7 @@ distribution.
# define __has_cpp_attribute(x) 0
#endif

-#if defined(_MSC_VER)
-# define TIXML_FALLTHROUGH (void(0))
-#elif (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
+#if (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
# define TIXML_FALLTHROUGH [[fallthrough]]
#elif __has_cpp_attribute(clang::fallthrough)
# define TIXML_FALLTHROUGH [[clang::fallthrough]]
@@ -53,15 +51,8 @@ distribution.
#endif


-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
- // Microsoft Visual Studio, version 2005 and higher. Not WinCE.
- /*int _snprintf_s(
- char *buffer,
- size_t sizeOfBuffer,
- size_t count,
- const char *format [,
- argument] ...
- );*/
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+ // Microsoft Visual Studio, version 2005 and higher.
static inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
{
va_list va;
@@ -80,33 +71,11 @@ distribution.
#define TIXML_VSCPRINTF _vscprintf
#define TIXML_SSCANF sscanf_s
#elif defined _MSC_VER
- // Microsoft Visual Studio 2003 and earlier or WinCE
+ // Microsoft Visual Studio 2003 and earlier.
#define TIXML_SNPRINTF _snprintf
#define TIXML_VSNPRINTF _vsnprintf
#define TIXML_SSCANF sscanf
- #if (_MSC_VER < 1400 ) && (!defined WINCE)
- // Microsoft Visual Studio 2003 and not WinCE.
- #define TIXML_VSCPRINTF _vscprintf // VS2003's C runtime has this, but VC6 C runtime or WinCE SDK doesn't have.
- #else
- // Microsoft Visual Studio 2003 and earlier or WinCE.
- static inline int TIXML_VSCPRINTF( const char* format, va_list va )
- {
- int len = 512;
- for (;;) {
- len = len*2;
- char* str = new char[len]();
- const int required = _vsnprintf(str, len, format, va);
- delete[] str;
- if ( required != -1 ) {
- TIXMLASSERT( required >= 0 );
- len = required;
- break;
- }
- }
- TIXMLASSERT( len >= 0 );
- return len;
- }
- #endif
+ #define TIXML_VSCPRINTF _vscprintf
#else
// GCC version 3 and higher
//#warning( "Using sn* functions." )
@@ -114,6 +83,9 @@ distribution.
#define TIXML_VSNPRINTF vsnprintf
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
{
+ if (!format) {
+ return 0;
+ }
int len = vsnprintf( 0, 0, format, va );
TIXMLASSERT( len >= 0 );
return len;
@@ -121,7 +93,7 @@ distribution.
#define TIXML_SSCANF sscanf
#endif

-#if defined(_WIN64)
+#if defined(_MSC_VER)
#define TIXML_FSEEK _fseeki64
#define TIXML_FTELL _ftelli64
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__CYGWIN__)
@@ -549,12 +521,15 @@ const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length)
TIXMLASSERT(digit < radix);

const unsigned int digitScaled = mult * digit;
+ // Reject before adding: if digitScaled alone exceeds MAX_CODE_POINT,
+ // or if adding it to ucs would exceed it (checked without overflow by
+ // testing ucs > MAX_CODE_POINT - digitScaled, safe since digitScaled
+ // <= MAX_CODE_POINT at this point).
+ if (digitScaled > MAX_CODE_POINT || ucs > MAX_CODE_POINT - digitScaled) {
+ return 0;
+ }
ucs += digitScaled;
mult *= radix;
-
- // Security check: could a value exist that is out of range?
- // Easily; limit to the MAX_CODE_POINT, which also allows for a
- // bunch of leading zeroes.
if (mult > MAX_CODE_POINT) {
mult = MAX_CODE_POINT;
}
@@ -566,11 +541,11 @@ const char* XMLUtil::GetCharacterRef(const char* p, char* value, int* length)
}
// convert the UCS to UTF-8
ConvertUTF32ToUTF8(ucs, value, length);
- if (length == 0) {
- // If length is 0, there was an error. (Security? Bad input?)
+ if (*length == 0) {
+ // If *length is 0, ConvertUTF32ToUTF8 rejected the code point.
// Fail safely.
- return 0;
- }
+ return 0;
+ }
return p + delta + 1;
}
return p + 1;
@@ -831,7 +806,17 @@ XMLNode::XMLNode( XMLDocument* doc ) :

XMLNode::~XMLNode()
{
- DeleteChildren();
+ // Fast path: this node is dying, so maintaining _firstChild/_lastChild and
+ // sibling _prev/_next links is unnecessary. Only _parent must be zeroed to
+ // satisfy the MarkInUse assertion inside DeleteNode.
+ XMLNode *currentChild = _firstChild;
+ while (currentChild != NULL) {
+ XMLNode *next = currentChild->_next;
+ currentChild->_parent = 0;
+ DeleteNode(currentChild);
+ currentChild = next;
+ }
+
if ( _parent ) {
_parent->Unlink( this );
}
@@ -2332,7 +2317,7 @@ static FILE* callfopen( const char* filepath, const char* mode )
{
TIXMLASSERT( filepath );
TIXMLASSERT( mode );
-#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
FILE* fp = 0;
const errno_t err = fopen_s( &fp, filepath, mode );
if ( err ) {
@@ -2345,8 +2330,10 @@ static FILE* callfopen( const char* filepath, const char* mode )
}

void XMLDocument::DeleteNode( XMLNode* node ) {
- TIXMLASSERT( node );
- TIXMLASSERT(node->_document == this );
+ if(node == 0) {
+ return; // check for null pointer
+ }
+ TIXMLASSERT(node->_document == this);
if (node->_parent) {
node->_parent->DeleteChild( node );
}
diff --git a/far/thirdparty/tinyxml2/tinyxml2.h b/far/thirdparty/tinyxml2/tinyxml2.h
index 88b3257e9..a4a34765a 100644
--- a/far/thirdparty/tinyxml2/tinyxml2.h
+++ b/far/thirdparty/tinyxml2/tinyxml2.h
@@ -24,15 +24,12 @@ distribution.
#ifndef TINYXML2_INCLUDED
#define TINYXML2_INCLUDED

-#if defined(ANDROID_NDK) || defined(__BORLANDC__) || defined(__QNXNTO__)
+#if defined(ANDROID_NDK)
# include <ctype.h>
# include <limits.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
-# if defined(__PS3__)
-# include <stddef.h>
-# endif
#else
# include <cctype>
# include <climits>
@@ -42,14 +39,6 @@ distribution.
#endif
#include <stdint.h>

-/*
- gcc:
- g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
-
- Formatting, Artistic Style:
- AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
-*/
-
#if defined( _DEBUG ) || defined (__DEBUG__)
# ifndef TINYXML2_DEBUG
# define TINYXML2_DEBUG
@@ -93,12 +82,20 @@ distribution.
#endif
#endif

+#if defined(__cplusplus) && __cplusplus >= 201703L
+#define TINYXML2_CONSTANT inline constexpr
+#elif defined(__cplusplus) && __cplusplus >= 201103L
+#define TINYXML2_CONSTANT static constexpr
+#else
+#define TINYXML2_CONSTANT static const
+#endif
+
/* Versioning, past 1.0.14:
http://semver.org/
*/
-static const int TIXML2_MAJOR_VERSION = 11;
-static const int TIXML2_MINOR_VERSION = 0;
-static const int TIXML2_PATCH_VERSION = 0;
+TINYXML2_CONSTANT int TIXML2_MAJOR_VERSION = 11;
+TINYXML2_CONSTANT int TIXML2_MINOR_VERSION = 0;
+TINYXML2_CONSTANT int TIXML2_PATCH_VERSION = 0;

#define TINYXML2_MAJOR_VERSION 11
#define TINYXML2_MINOR_VERSION 0
@@ -109,7 +106,7 @@ static const int TIXML2_PATCH_VERSION = 0;
// system, and the capacity of the stack. On the other hand, it's a trivial
// attack that can result from ill, malicious, or even correctly formed XML,
// so there needs to be a limit in place.
-static const int TINYXML2_MAX_ELEMENT_DEPTH = 500;
+TINYXML2_CONSTANT int TINYXML2_MAX_ELEMENT_DEPTH = 500;

namespace tinyxml2
{


Reply all
Reply to author
Forward
0 new messages