Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Commit

Permalink
Merge pull request #328 from ksmyth/null_iterator_crash
Browse files Browse the repository at this point in the history
Fix crash when derefencing null iterator
  • Loading branch information
pksunkara committed May 28, 2015
2 parents f1aef0e + b3e809c commit d2e57f8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/BlueprintParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ namespace snowcrash {
++elementIt) {

if (elementIt->element == Element::CategoryElement) {
checkResourceLazyReferencing(*elementIt, *elementSourceMapIt, pd, out);
checkResourceLazyReferencing(*elementIt, elementSourceMapIt, pd, out);
}

if (pd.exportSourceMap()) {
Expand All @@ -655,22 +655,27 @@ namespace snowcrash {

/** Traverses Resource Collection to resolve references with `Pending` state (Lazy referencing) */
static void checkResourceLazyReferencing(Element& element,
SourceMap<Element>& elementSourceMap,
Collection<SourceMap<Element> >::iterator& elementSourceMap,
SectionParserData& pd,
const ParseResultRef<Blueprint>& out) {

Collection<SourceMap<Element> >::iterator resourceElementSourceMapIt;

if (pd.exportSourceMap()) {
resourceElementSourceMapIt = elementSourceMap.content.elements().collection.begin();
resourceElementSourceMapIt = elementSourceMap->content.elements().collection.begin();
}

for (Elements::iterator resourceElementIt = element.content.elements().begin();
resourceElementIt != element.content.elements().end();
++resourceElementIt) {

if (resourceElementIt->element == Element::ResourceElement) {
checkActionLazyReferencing(resourceElementIt->content.resource, resourceElementSourceMapIt->content.resource, pd, out);
if (pd.exportSourceMap()) {
checkActionLazyReferencing(resourceElementIt->content.resource, resourceElementSourceMapIt->content.resource, pd, out);
} else {
SourceMap<Resource> tempSourceMap;
checkActionLazyReferencing(resourceElementIt->content.resource, tempSourceMap, pd, out);
}
}

if (pd.exportSourceMap()) {
Expand Down Expand Up @@ -705,7 +710,7 @@ namespace snowcrash {

/** Traverses Transaction Example Collection AST to resolve references with `Pending` state (Lazy referencing) */
static void checkExampleLazyReferencing(Action& action,
Collection<SourceMap<Action> >::iterator actionSourceMapIt,
Collection<SourceMap<Action> >::iterator& actionSourceMapIt,
SectionParserData& pd,
const ParseResultRef<Blueprint>& out) {

Expand All @@ -730,7 +735,7 @@ namespace snowcrash {

/** Traverses Request Collection to resolve references with `Pending` state (Lazy referencing) */
static void checkRequestLazyReferencing(TransactionExample& transactionExample,
Collection<SourceMap<TransactionExample> >::iterator transactionExampleSourceMapIt,
Collection<SourceMap<TransactionExample> >::iterator& transactionExampleSourceMapIt,
SectionParserData& pd,
const ParseResultRef<Blueprint>& out) {

Expand Down Expand Up @@ -770,7 +775,7 @@ namespace snowcrash {

/** Traverses Response Collection to resolve references with `Pending` state (Lazy referencing) */
static void checkResponseLazyReferencing(TransactionExample& transactionExample,
Collection<SourceMap<TransactionExample> >::iterator transactionExampleSourceMapIt,
Collection<SourceMap<TransactionExample> >::iterator& transactionExampleSourceMapIt,
SectionParserData& pd,
const ParseResultRef<Blueprint>& out) {

Expand Down

0 comments on commit d2e57f8

Please sign in to comment.