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