Coverage Report

Created: 2025-06-13 07:02

/src/xerces_fuzz_common.cpp
Line
Count
Source
1
/*
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#      http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
#
15
################################################################################
16
*/
17
#include "xerces_fuzz_common.h"
18
19
using namespace xercesc_3_2;
20
static bool initialized = false;
21
22
void parseInMemory(const uint8_t *Data, size_t Size)
23
15.3k
{
24
15.3k
    if (!initialized)
25
2
    {
26
2
        XMLPlatformUtils::Initialize();
27
2
        initialized = true;
28
2
    }
29
15.3k
    SAXParser::ValSchemes valScheme = SAXParser::Val_Auto;
30
15.3k
    bool doNamespaces = false;
31
15.3k
    bool doSchema = false;
32
15.3k
    bool schemaFullChecking = false;
33
15.3k
    SAXParser *parser = new SAXParser;
34
15.3k
    parser->setValidationScheme(valScheme);
35
15.3k
    parser->setDoNamespaces(doNamespaces);
36
15.3k
    parser->setDoSchema(doSchema);
37
15.3k
    parser->setHandleMultipleImports(true);
38
15.3k
    parser->setValidationSchemaFullChecking(schemaFullChecking);
39
15.3k
    static const char *gMemBufId = "prodInfo";
40
41
15.3k
    MemBufInputSource *memBufIS = new MemBufInputSource(
42
15.3k
        (const XMLByte *)Data, Size, gMemBufId, false);
43
15.3k
    parser->parse(*memBufIS);
44
15.3k
    delete parser;
45
15.3k
    delete memBufIS;
46
    //XMLPlatformUtils::Terminate();
47
15.3k
}