The expression is always false
https://gitlab.gnome.org/GNOME/libxml2/-/blob/master/xmlsave.c#L2136
int ret;
...
if (ret > INT_MAX)
return(-1);
The conditional expression doesn't make sense. You should implement overflow checking in a different way.