Browse Source

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

git-svn-id: trunk@43354 -
michael 5 years ago
parent
commit
078534472b
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