@@ -185,7 +185,7 @@ void symbolic_constant_print(const struct symbol_table *tbl,
struct output_ctx *octx)
{
unsigned int len = div_round_up(expr->len, BITS_PER_BYTE);
- const struct symbolic_constant *s;
+ const struct symbolic_constant *s = NULL;
uint64_t val = 0;
/* Export the data in the correct byteorder for comparison */
@@ -193,12 +193,14 @@ void symbolic_constant_print(const struct symbol_table *tbl,
mpz_export_data(constant_data_ptr(val, expr->len), expr->value,
expr->byteorder, len);
- for (s = tbl->symbols; s->identifier != NULL; s++) {
- if (val == s->value)
- break;
- }
+ if (tbl != NULL)
+ for (s = tbl->symbols; s->identifier != NULL; s++) {
+ if (val == s->value)
+ break;
+ }
- if (s->identifier == NULL || nft_output_numeric_symbol(octx))
+ if (s == NULL || s->identifier == NULL ||
+ nft_output_numeric_symbol(octx))
return expr_basetype(expr)->print(expr, octx);
nft_print(octx, quotes ? "\"%s\"" : "%s", s->identifier);
If the symbol-table passed to `symbol_constant_print` is `NULL`, fall back to printing the expression's base-type. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> --- src/datatype.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)