• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
parseInMemory(const uint8_t * Data,size_t Size)22 void parseInMemory(const uint8_t *Data, size_t Size)
23 {
24     if (!initialized)
25     {
26         XMLPlatformUtils::Initialize();
27         initialized = true;
28     }
29     SAXParser::ValSchemes valScheme = SAXParser::Val_Auto;
30     bool doNamespaces = false;
31     bool doSchema = false;
32     bool schemaFullChecking = false;
33     SAXParser *parser = new SAXParser;
34     parser->setValidationScheme(valScheme);
35     parser->setDoNamespaces(doNamespaces);
36     parser->setDoSchema(doSchema);
37     parser->setHandleMultipleImports(true);
38     parser->setValidationSchemaFullChecking(schemaFullChecking);
39     static const char *gMemBufId = "prodInfo";
40 
41     MemBufInputSource *memBufIS = new MemBufInputSource(
42         (const XMLByte *)Data, Size, gMemBufId, false);
43     parser->parse(*memBufIS);
44     delete parser;
45     delete memBufIS;
46     //XMLPlatformUtils::Terminate();
47 }
48