diff --git a/src/librexgen/iterator/caseiterator.cpp b/src/librexgen/iterator/caseiterator.cpp index 4e7ecc1..2c8fa17 100644 --- a/src/librexgen/iterator/caseiterator.cpp +++ b/src/librexgen/iterator/caseiterator.cpp @@ -28,7 +28,7 @@ CaseIterator::CaseIterator(Iterator* __child, int options) } CaseIterator::~CaseIterator() { - if (child != NULL) { + if (child != NULL && (! child->isSingleton())) { delete child; } } diff --git a/src/librexgen/iterator/iteratorstate.h b/src/librexgen/iterator/iteratorstate.h index f2923ea..0b62cb7 100644 --- a/src/librexgen/iterator/iteratorstate.h +++ b/src/librexgen/iterator/iteratorstate.h @@ -25,6 +25,7 @@ #include #include #include +#include class IteratorState { public: @@ -34,6 +35,7 @@ class IteratorState { virtual ~IteratorState() { if (streamIterator != NULL) { delete streamIterator; + streamIterator = NULL; } } @@ -57,6 +59,8 @@ class IteratorState { void setStreamIterator(StreamRegexIterator* iter) { if (streamIterator == NULL) { streamIterator = iter; + } else { + throw std::runtime_error("multiple stream iterator assignment"); } } diff --git a/src/rexgen/rexgen.c b/src/rexgen/rexgen.c index 66f1cfb..6444282 100644 --- a/src/rexgen/rexgen.c +++ b/src/rexgen/rexgen.c @@ -168,13 +168,21 @@ const char* rexgen_parse_arguments(int argc, _TCHAR** argv) { */ size_t callback(char* dst, const size_t buffer_size) { + size_t len = 0; + while (len == 0) { + /* read next word */ + if (fgets(dst, buffer_size, infile) == NULL) { + return 0; + } - /* read next word */ - if (fgets((char*)dst, buffer_size, infile) == NULL) { - return 0; + /* remove trailing newlines */ + len = strnlen(dst, buffer_size); + while (len > 0 && dst[len - 1] == '\n') { + --len; + dst[len] = '\0'; + } } - - return strlen((char*)dst); + return len; } int _tmain(int argc, _TCHAR* argv[]) { diff --git a/src/version.txt b/src/version.txt index 2165f8f..e010258 100644 --- a/src/version.txt +++ b/src/version.txt @@ -1 +1 @@ -2.0.4 +2.0.5