View Issue Details

IDProjectCategoryView StatusLast Update
0036243FPCPackagespublic2019-11-02 15:45
ReporterMichal GawryckiAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0036243: libxml - no 'xmlStrdup' function implemented
DescriptionThe 'xmlMemSetup' function requires all arguments, otherwise it will not work.

https://github.com/GNOME/libxml2/blob/41a34e1f4ffae2ce401600dbb5fe43f8fe402641/xmlmemory.c#L1053

There is currently no implementation of the fpcxmlStrdup function, so 'xmlMemSetup' does nothing.
Patch included.
TagsNo tags attached.
Fixed in Revision43354
FPCOldBugId
FPCTarget3.2.0
Attached Files
  • xml2_strdup.patch (824 bytes)
    Index: packages/libxml/src/xml2.pas
    ===================================================================
    --- packages/libxml/src/xml2.pas	(revision 43044)
    +++ packages/libxml/src/xml2.pas	(working copy)
    @@ -50,6 +50,16 @@
       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 @@
     (*
      * overloading the memory functions
      *)
    -  xmlMemSetup(@fpcxmlFree, @fpcxmlMalloc, @fpcxmlRealloc, nil);
    +  xmlMemSetup(@fpcxmlFree, @fpcxmlMalloc, @fpcxmlRealloc, @fpcxmlStrdup);
     
     (*
      * overloading the error functions
    
    xml2_strdup.patch (824 bytes)

Activities

Michal Gawrycki

2019-11-01 18:07

reporter  

xml2_strdup.patch (824 bytes)
Index: packages/libxml/src/xml2.pas
===================================================================
--- packages/libxml/src/xml2.pas	(revision 43044)
+++ packages/libxml/src/xml2.pas	(working copy)
@@ -50,6 +50,16 @@
   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 @@
 (*
  * overloading the memory functions
  *)
-  xmlMemSetup(@fpcxmlFree, @fpcxmlMalloc, @fpcxmlRealloc, nil);
+  xmlMemSetup(@fpcxmlFree, @fpcxmlMalloc, @fpcxmlRealloc, @fpcxmlStrdup);
 
 (*
  * overloading the error functions
xml2_strdup.patch (824 bytes)

Michael Van Canneyt

2019-11-02 11:29

administrator   ~0118971

Checked & applied the patch, thank you very much!

Michal Gawrycki

2019-11-02 15:45

reporter   ~0118984

Thanks. Closed.

Issue History

Date Modified Username Field Change
2019-11-01 18:07 Michal Gawrycki New Issue
2019-11-01 18:07 Michal Gawrycki File Added: xml2_strdup.patch
2019-11-02 10:14 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-11-02 10:14 Michael Van Canneyt Status new => assigned
2019-11-02 11:29 Michael Van Canneyt Status assigned => resolved
2019-11-02 11:29 Michael Van Canneyt Resolution open => fixed
2019-11-02 11:29 Michael Van Canneyt Fixed in Version => 3.3.1
2019-11-02 11:29 Michael Van Canneyt Fixed in Revision => 43354
2019-11-02 11:29 Michael Van Canneyt FPCTarget => 3.2.0
2019-11-02 11:29 Michael Van Canneyt Note Added: 0118971
2019-11-02 15:45 Michal Gawrycki Status resolved => closed
2019-11-02 15:45 Michal Gawrycki Note Added: 0118984