Skip to content
Snippets Groups Projects
Commit f930f138 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#5286] Fix parsing error due to long configuration file (removed max event)

parent 7bb3770f
Branches
No related tags found
No related merge requests found
...@@ -39,6 +39,8 @@ namespace Conf ...@@ -39,6 +39,8 @@ namespace Conf
{ {
YamlParser::YamlParser (const char *file) : filename (file) YamlParser::YamlParser (const char *file) : filename (file)
, fd(NULL)
, events()
, eventNumber (0) , eventNumber (0)
, doc (NULL) , doc (NULL)
, eventIndex (0) , eventIndex (0)
...@@ -97,7 +99,7 @@ void YamlParser::close() throw(YamlParserException) ...@@ -97,7 +99,7 @@ void YamlParser::close() throw(YamlParserException)
void YamlParser::serializeEvents() throw(YamlParserException) void YamlParser::serializeEvents() throw(YamlParserException)
{ {
bool done = false; bool done = false;
yaml_event_t event; yaml_event_t event, copiedEvent;
try { try {
...@@ -108,16 +110,16 @@ void YamlParser::serializeEvents() throw(YamlParserException) ...@@ -108,16 +110,16 @@ void YamlParser::serializeEvents() throw(YamlParserException)
done = (event.type == YAML_STREAM_END_EVENT); done = (event.type == YAML_STREAM_END_EVENT);
if (eventNumber > PARSER_MAXEVENT) copyEvent (&copiedEvent, &event);
throw YamlParserException ("Reached maximum of event");
copyEvent (& (events[eventNumber++]), &event); events.push_back(copiedEvent);
eventNumber++;
yaml_event_delete (&event); yaml_event_delete (&event);
} }
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error ("YamlParserException: %s", e.what());
throw; throw;
} }
...@@ -233,7 +235,6 @@ YamlDocument *YamlParser::composeEvents() throw(YamlParserException) ...@@ -233,7 +235,6 @@ YamlDocument *YamlParser::composeEvents() throw(YamlParserException)
processStream(); processStream();
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error ("YamlParserException: %s", e.what());
throw; throw;
} }
...@@ -256,7 +257,6 @@ void YamlParser::processStream () throw(YamlParserException) ...@@ -256,7 +257,6 @@ void YamlParser::processStream () throw(YamlParserException)
throw YamlParserException ("Did not found end of stream"); throw YamlParserException ("Did not found end of stream");
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error ("YamlParserException: %s", e.what());
throw; throw;
} }
} }
...@@ -294,7 +294,6 @@ void YamlParser::processDocument() throw(YamlParserException) ...@@ -294,7 +294,6 @@ void YamlParser::processDocument() throw(YamlParserException)
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error("YamlParserException: %s", e.what());
throw; throw;
} }
} }
...@@ -327,7 +326,6 @@ void YamlParser::processScalar (YamlNode *topNode) throw(YamlParserException) ...@@ -327,7 +326,6 @@ void YamlParser::processScalar (YamlNode *topNode) throw(YamlParserException)
} }
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error("YamlParserException %s", e.what());
throw; throw;
} }
} }
...@@ -383,7 +381,6 @@ void YamlParser::processSequence (YamlNode *topNode) throw(YamlParserException) ...@@ -383,7 +381,6 @@ void YamlParser::processSequence (YamlNode *topNode) throw(YamlParserException)
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error("YamlParserException %s", e.what());
throw; throw;
} }
...@@ -447,7 +444,6 @@ void YamlParser::processMapping (YamlNode *topNode) throw(YamlParserException) ...@@ -447,7 +444,6 @@ void YamlParser::processMapping (YamlNode *topNode) throw(YamlParserException)
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error("YamlParserException %s", e.what());
throw; throw;
} }
} }
...@@ -489,7 +485,6 @@ void YamlParser::constructNativeData() throw(YamlParserException) ...@@ -489,7 +485,6 @@ void YamlParser::constructNativeData() throw(YamlParserException)
} }
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error("YamlParserException %s", e.what());
throw; throw;
} }
...@@ -542,7 +537,6 @@ void YamlParser::mainNativeDataMapping (MappingNode *map) throw(YamlParserExcept ...@@ -542,7 +537,6 @@ void YamlParser::mainNativeDataMapping (MappingNode *map) throw(YamlParserExcept
} }
} }
catch(YamlParserException &e) { catch(YamlParserException &e) {
_error("YamlParserException %s", e.what());
throw; throw;
} }
} }
......
...@@ -36,12 +36,14 @@ ...@@ -36,12 +36,14 @@
#include <stdio.h> #include <stdio.h>
#include <exception> #include <exception>
#include <string> #include <string>
#include <vector>
namespace Conf namespace Conf
{ {
#define PARSER_BUFFERSIZE 65536 #define PARSER_BUFFERSIZE 65536
#define PARSER_MAXEVENT 1024
typedef std::vector<yaml_event_t> YamlEventVector;
class YamlParserException : public std::exception class YamlParserException : public std::exception
{ {
...@@ -145,7 +147,7 @@ class YamlParser ...@@ -145,7 +147,7 @@ class YamlParser
/** /**
* The event structure array. * The event structure array.
*/ */
yaml_event_t events[PARSER_MAXEVENT]; YamlEventVector events;
/** /**
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment