Browse Source

* Merging revisions r43354 from trunk:
------------------------------------------------------------------------
r43354 | michael | 2019-11-02 11:28:27 +0100 (Sat, 02 Nov 2019) | 1 line

* Patch from Michal Gawrycki to handle duplicating strings (bug ID 36243)
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@43732 -

michael 5 years ago
parent
commit
33e004a0a3
1 changed files with 11 additions and 1 deletions
  1. 11 1
      packages/libxml/src/xml2.pas

+ 11 - 1
packages/libxml/src/xml2.pas

@@ -50,6 +50,16 @@ begin
   ReallocMem(Result, size);
 end;
 
+function fpcxmlStrdup(str: pchar): pchar; EXTDECL;
+var
+  L: SizeInt;
+begin
+  L := Length(str) + 1;
+  Getmem(Result, L);
+  if Result <> nil then
+    Move(str^, Result^, L);
+end;
+
 procedure fpcxmlStructuredErrorHandler(userData: pointer; error: xmlErrorPtr); EXTDECL;
 begin
   writeln('struct error');
@@ -303,7 +313,7 @@ initialization
 (*
  * overloading the memory functions
  *)
-  xmlMemSetup(@fpcxmlFree, @fpcxmlMalloc, @fpcxmlRealloc, nil);
+  xmlMemSetup(@fpcxmlFree, @fpcxmlMalloc, @fpcxmlRealloc, @fpcxmlStrdup);
 
 (*
  * overloading the error functions