* xmlVRaiseError: * @schannel: the structured callback channel * @channel: the old callback channel * @data: the callback data * @ctx: the parser context or NULL * @node: the current node or NULL * @domain: the domain for the error * @code: the code for the error * @level: the xmlErrorLevel for the error * @file: the file source of the error (or NULL) * @line: the line of the error or 0
| 685 | * Returns 0 on success, -1 if a memory allocation failed. |
| 686 | */ |
| 687 | int |
| 688 | xmlVRaiseError(xmlStructuredErrorFunc schannel, |
| 689 | xmlGenericErrorFunc channel, void *data, void *ctx, |
| 690 | xmlNode *node, int domain, int code, xmlErrorLevel level, |
| 691 | const char *file, int line, const char *str1, |
| 692 | const char *str2, const char *str3, int int1, int col, |
| 693 | const char *msg, va_list ap) |
| 694 | { |
| 695 | xmlParserCtxtPtr ctxt = NULL; |
| 696 | /* xmlLastError is a macro retrieving the per-thread global. */ |
| 697 | xmlErrorPtr lastError = &xmlLastError; |
| 698 | xmlErrorPtr to = lastError; |
| 699 | |
| 700 | if (code == XML_ERR_OK) |
| 701 | return(0); |
| 702 | #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION |
| 703 | if (code == XML_ERR_INTERNAL_ERROR) { |
| 704 | fprintf(stderr, "Unexpected error: %d\n", code); |
| 705 | abort(); |
| 706 | } |
| 707 | #endif |
| 708 | if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING)) |
| 709 | return(0); |
| 710 | |
| 711 | if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) || |
| 712 | (domain == XML_FROM_DTD) || (domain == XML_FROM_NAMESPACE) || |
| 713 | (domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) { |
| 714 | ctxt = (xmlParserCtxtPtr) ctx; |
| 715 | |
| 716 | if (ctxt != NULL) |
| 717 | to = &ctxt->lastError; |
| 718 | } |
| 719 | |
| 720 | if (xmlVUpdateError(to, ctxt, node, domain, code, level, file, line, |
| 721 | str1, str2, str3, int1, col, msg, ap)) |
| 722 | return(-1); |
| 723 | |
| 724 | if (to != lastError) { |
| 725 | if (xmlCopyError(to, lastError) < 0) |
| 726 | return(-1); |
| 727 | } |
| 728 | |
| 729 | if (schannel != NULL) { |
| 730 | schannel(data, to); |
| 731 | } else if (xmlStructuredError != NULL) { |
| 732 | xmlStructuredError(xmlStructuredErrorContext, to); |
| 733 | } else if (channel != NULL) { |
| 734 | /* Don't invoke legacy error handlers */ |
| 735 | if ((channel == xmlGenericErrorDefaultFunc) || |
| 736 | (channel == xmlParserError) || |
| 737 | (channel == xmlParserWarning) || |
| 738 | (channel == xmlParserValidityError) || |
| 739 | (channel == xmlParserValidityWarning)) |
| 740 | xmlFormatError(to, xmlGenericError, xmlGenericErrorContext); |
| 741 | else |
| 742 | channel(data, "%s", to->message); |
| 743 | } |
| 744 |
no test coverage detected