/* Test that the unknown encoding handler with map entries that expect
* conversion but no conversion function is faulted
*/
+static int XMLCALL
+failing_converter(void *UNUSED_P(data), const char *UNUSED_P(s))
+{
+ /* Always claim to have failed */
+ return -1;
+}
+
static int XMLCALL
BadEncodingHandler(void *data,
const XML_Char *UNUSED_P(encoding),
for (; i < 256; ++i)
info->map[i] = -2; /* A 2-byte sequence */
info->data = NULL;
- info->convert = (int (XMLCALL *)(void *, const char *))data;
+ info->convert = (data == NULL) ? NULL : failing_converter;
info->release = NULL;
return XML_STATUS_OK;
}
}
END_TEST
-static int XMLCALL
-failing_converter(void *UNUSED_P(data), const char *UNUSED_P(s))
-{
- /* Always claim to have failed */
- return -1;
-}
-
START_TEST(test_failing_encoding_conversion_fn)
{
const char *text =
"<doc>\x81</doc>";
XML_SetUnknownEncodingHandler(parser, BadEncodingHandler,
- (void *)failing_converter);
+ /* Anything non-NULL will do here */
+ (void *)(intptr_t)1);
/* BadEncodingHandler sets up an encoding with every top-bit-set
* character introducing a two-byte sequence. For this, it
* requires a convert function. The above function call passes