dfilter: Cleanup handling of null/empty expressions

This commit is contained in:
João Valverde 2023-04-21 00:26:53 +01:00
parent 43117dd40f
commit 435a2186ab
2 changed files with 12 additions and 15 deletions

View File

@ -450,23 +450,20 @@ dfilter_compile_full(const gchar *text, dfilter_t **dfp,
*dfp = NULL;
if (text == NULL) {
ws_debug("%s() called from %s() with null filter",
__func__, caller);
/* XXX This BUG happens often. Some callers are ignoring these errors. */
ws_warning("Called from %s() with null filter", caller);
if (err_ptr)
*err_ptr = df_error_new_msg("BUG: NULL text pointer passed to dfilter_compile");
*err_ptr = df_error_new_msg("BUG: NULL text pointer");
return FALSE;
}
else if (*text == '\0') {
/* An empty filter is considered a valid input. */
ws_debug("%s() called from %s() with empty filter",
__func__, caller);
}
else {
ws_debug("%s() called from %s(), compiling filter: %s",
__func__, caller, text);
if (*text == '\0') {
ws_warning("Called from %s() with empty filter", caller);
if (err_ptr)
*err_ptr = df_error_new_msg("Filter expression is empty");
return FALSE;
}
ws_debug("Called from %s() with filter: %s", caller, text);
dfw = dfwork_new(flags);
if (flags & DF_EXPAND_MACROS) {

View File

@ -554,7 +554,7 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
tl->needs_redraw=TRUE;
tl->failed=FALSE;
tl->flags=flags;
if(fstring){
if(fstring && *fstring){
if(!dfilter_compile(fstring, &code, &df_err)){
error_string = g_string_new("");
g_string_printf(error_string,
@ -564,9 +564,9 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
free_tap_listener(tl);
return error_string;
}
tl->fstring=g_strdup(fstring);
tl->code=code;
}
tl->fstring=g_strdup(fstring);
tl->code=code;
tl->tap_id=tap_id;
tl->tapdata=tapdata;