Do not free stream unless hs_close_stream returns success.

(by unit-hyperscan HyperscanArgChecks.CloseStreamNoScratch)
This commit is contained in:
Chang, Harry 2019-06-20 08:59:18 +08:00
parent 4b1927c038
commit 8bfbf07f75

View File

@ -1006,17 +1006,14 @@ hs_error_t HS_CDECL hs_close_stream(hs_stream_t *id, hs_scratch_t *scratch,
if (onEvent) { if (onEvent) {
if (!scratch || !validScratch(id->rose, scratch)) { if (!scratch || !validScratch(id->rose, scratch)) {
hs_stream_free(id);
return HS_INVALID; return HS_INVALID;
} }
if (unlikely(markScratchInUse(scratch))) { if (unlikely(markScratchInUse(scratch))) {
hs_stream_free(id);
return HS_SCRATCH_IN_USE; return HS_SCRATCH_IN_USE;
} }
report_eod_matches(id, scratch, onEvent, context); report_eod_matches(id, scratch, onEvent, context);
if (unlikely(internal_matching_error(scratch))) { if (unlikely(internal_matching_error(scratch))) {
unmarkScratchInUse(scratch); unmarkScratchInUse(scratch);
hs_stream_free(id);
return HS_UNKNOWN_ERROR; return HS_UNKNOWN_ERROR;
} }
unmarkScratchInUse(scratch); unmarkScratchInUse(scratch);