[xml/sgml-pkgs] Bug#1111626: libxml2: initGenericErrorDefaultFunc(NULL) fails to compile

Samuel Thibault sthibault at debian.org
Wed Aug 20 09:32:27 BST 2025


Package: libxml2
Version: 2.14.5+dfsg-0.1
Severity: serious
Tags: patch upstream
Justification: Makes packages FTBFS
Forwarded: https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/336

Hello,

This simple program fails to build:

#include <stddef.h>
#include <libxml/xmlerror.h>
int main(void) {
        initGenericErrorDefaultFunc(NULL);
}

/usr/include/libxml2/libxml/xmlerror.h:23:45: error: invalid use of void expression
       23 |     xmlSetGenericErrorFunc(NULL, (h) ? *(h) : NULL)

The compatibility macro is indeed wrong in the NULL case. The attached
patch, submitted upstream, fixes this.

Samuel

-- System Information:
Debian Release: 13.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'testing-debug'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'oldoldstable-proposed-updates-debug'), (500, 'oldoldstable'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, arm64

Kernel: Linux 6.16.0 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libxml2 depends on:
ii  libc6     2.41-11
ii  liblzma5  5.8.1-1
ii  zlib1g    1:1.3.dfsg+really1.3.1-1+b1

libxml2 recommends no packages.

libxml2 suggests no packages.

-- no debconf information
-------------- next part --------------
commit 5bd6b44d139758652a259ee8cead6d8c61692fe3
Author: Samuel Thibault <samuel.thibault at ens-lyon.org>
Date:   Wed Aug 20 10:18:25 2025 +0200

    Fix initGenericErrorDefaultFunc(NULL)
    
    Calling initGenericErrorDefaultFunc(NULL) currently yields to
    
    /usr/include/libxml2/libxml/xmlerror.h:23:45: error: invalid use of void expression
       23 |     xmlSetGenericErrorFunc(NULL, (h) ? *(h) : NULL)
    
    Indeed, even if h is nul, the compiler will try to give a type to *(h),
    which can't work.

diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index 0cd4e1b5..017411e4 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -25,7 +25,7 @@ extern "C" {
  * @deprecated Use #xmlSetGenericErrorFunc
  */
 #define initGenericErrorDefaultFunc(h) \
-    xmlSetGenericErrorFunc(NULL, (h) ? *(h) : NULL)
+    xmlSetGenericErrorFunc(NULL, (h) ? *((xmlGenericErrorFunc *) (h)) : NULL)
 
 /**
  * Indicates the level of an error


More information about the debian-xml-sgml-pkgs mailing list