if (flags & STREAM_GAP) {
if (!(p->option_flags & APP_LAYER_PARSER_OPT_ACCEPT_GAPS)) {
SCLogDebug("app-layer parser does not accept gaps");
- if (f->alstate != NULL) {
+ if (f->alstate != NULL && !FlowChangeProto(f)) {
AppLayerParserStreamTruncated(f->proto, alproto, f->alstate,
flags);
}
/* rerun protocol detection */
int rd = TCPProtoDetect(tv, ra_ctx, app_tctx, p, f, ssn, stream, data, data_len, flags);
if (f->alproto == ALPROTO_UNKNOWN) {
+ DEBUG_VALIDATE_BUG_ON(alstate_orig != f->alstate);
// not enough data, revert AppLayerProtoDetectReset to rerun detection
f->alparser = alparser;
f->alproto = f->alproto_orig;
} else {
FlowUnsetChangeProtoFlag(f);
AppLayerParserStateProtoCleanup(f->protomap, f->alproto_orig, alstate_orig, alparser);
+ if (alstate_orig == f->alstate) {
+ // we just freed it
+ f->alstate = NULL;
+ }
}
if (rd != 0) {
SCLogDebug("proto detect failure");
- f->alstate = NULL;
goto failure;
}
SCLogDebug("protocol change, old %s, new %s",