diff --git a/src/nfa/nfa_api_queue.h b/src/nfa/nfa_api_queue.h index 1373425d..59c18fca 100644 --- a/src/nfa/nfa_api_queue.h +++ b/src/nfa/nfa_api_queue.h @@ -91,6 +91,7 @@ struct mq { * history buffer; (logically) immediately before the * main buffer */ size_t hlength; /**< length of the history buffer */ + struct hs_scratch *scratch; /**< global scratch space */ char report_current; /**< * report_current matches at starting offset through * callback. If true, the queue must be located at a diff --git a/src/scratch.c b/src/scratch.c index d8742e7d..dae2c672 100644 --- a/src/scratch.c +++ b/src/scratch.c @@ -227,6 +227,11 @@ hs_error_t alloc_scratch(const hs_scratch_t *proto, hs_scratch_t **scratch) { // Don't get too big for your boots assert((size_t)(current - (char *)s) <= alloc_size); + // Init q->scratch ptr for every queue. + for (struct mq *qi = s->queues; qi != s->queues + queueCount; ++qi) { + qi->scratch = s; + } + return HS_SUCCESS; } diff --git a/unit/internal/lbr.cpp b/unit/internal/lbr.cpp index 2bb359df..f335e184 100644 --- a/unit/internal/lbr.cpp +++ b/unit/internal/lbr.cpp @@ -122,6 +122,7 @@ protected: q.length = 0; // filled in by test q.history = nullptr; q.hlength = 0; + q.scratch = nullptr; // not needed by LBR q.report_current = 0; q.cb = onMatch; q.som_cb = nullptr; // only used by Haig diff --git a/unit/internal/limex_nfa.cpp b/unit/internal/limex_nfa.cpp index 91ab09db..9d3c00b5 100644 --- a/unit/internal/limex_nfa.cpp +++ b/unit/internal/limex_nfa.cpp @@ -102,6 +102,7 @@ protected: q.length = SCAN_DATA.size(); q.history = nullptr; q.hlength = 0; + q.scratch = nullptr; /* limex does not use scratch */ q.report_current = 0; q.cb = onMatch; q.som_cb = nullptr; // only used by Haig @@ -396,6 +397,7 @@ protected: q.length = ZOMBIE_SCAN_DATA.length(); q.history = nullptr; q.hlength = 0; + q.scratch = nullptr; /* limex does not use scratch */ q.report_current = 0; q.cb = onMatch; q.som_cb = nullptr; // only used by Haig