Skip to content

Commit c883d95

Browse files
committed
Minor fix - check expr type before sending to char_array handler in printk_formatter
1 parent 5a8b64f commit c883d95

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pythonbpf/helper/printk_formatter.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,12 @@ def _prepare_expr_args(expr, func, module, builder, local_sym_tab, struct_sym_ta
220220
"""Evaluate and prepare an expression to use as an arg for bpf_printk."""
221221

222222
# Special case: struct field char array needs pointer to first element
223-
char_array_ptr, _ = get_char_array_ptr_and_size(
224-
expr, builder, local_sym_tab, struct_sym_tab
225-
)
226-
if char_array_ptr:
227-
return char_array_ptr
223+
if isinstance(expr, ast.Attribute):
224+
char_array_ptr, _ = get_char_array_ptr_and_size(
225+
expr, builder, local_sym_tab, struct_sym_tab
226+
)
227+
if char_array_ptr:
228+
return char_array_ptr
228229

229230
# Regular expression evaluation
230231
val, _ = eval_expr(func, module, builder, expr, local_sym_tab, None, struct_sym_tab)

0 commit comments

Comments
 (0)