Skip to content

Commit

Permalink
Merge pull request #46 from teeshop/issue/17
Browse files Browse the repository at this point in the history
Issue/17
  • Loading branch information
teeshop authored Jun 20, 2017
2 parents 3245b22 + 9775f31 commit 718e66b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librexgen/iterator/caseiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CaseIterator::CaseIterator(Iterator* __child, int options)
}

CaseIterator::~CaseIterator() {
if (child != NULL) {
if (child != NULL && (! child->isSingleton())) {
delete child;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/librexgen/iterator/iteratorstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <librexgen/regex/regex.h>
#include <map>
#include <algorithm>
#include <stdexcept>

class IteratorState {
public:
Expand All @@ -34,6 +35,7 @@ class IteratorState {
virtual ~IteratorState() {
if (streamIterator != NULL) {
delete streamIterator;
streamIterator = NULL;
}
}

Expand All @@ -57,6 +59,8 @@ class IteratorState {
void setStreamIterator(StreamRegexIterator* iter) {
if (streamIterator == NULL) {
streamIterator = iter;
} else {
throw std::runtime_error("multiple stream iterator assignment");
}
}

Expand Down
18 changes: 13 additions & 5 deletions src/rexgen/rexgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.4
2.0.5

0 comments on commit 718e66b

Please sign in to comment.