1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

testchar: Don't invoke encoding handler directly

This commit is contained in:
Nick Wellnhofer 2024-07-04 03:35:17 +02:00
parent 446a3610fd
commit 10082a3d54

View File

@ -751,21 +751,20 @@ error:
static char *
convert(xmlCharEncodingHandlerPtr handler, const char *utf8, int size,
int *outSize) {
xmlBufferPtr in, out;
char *ret;
int inlen;
int res;
inlen = size;
*outSize = size * 2;
ret = xmlMalloc(*outSize);
if (ret == NULL)
return(NULL);
res = handler->output(BAD_CAST ret, outSize, BAD_CAST utf8, &inlen);
if ((res < 0) || (inlen != size)) {
xmlFree(ret);
return(NULL);
}
in = xmlBufferCreate();
xmlBufferAdd(in, BAD_CAST utf8, size);
out = xmlBufferCreate();
xmlCharEncOutFunc(handler, out, in);
if (outSize)
*outSize = out->use;
ret = (char *) xmlBufferDetach(out);
xmlBufferFree(out);
xmlBufferFree(in);
return(ret);
}