print: add nullptr handling

This commit is contained in:
2026-03-16 11:54:55 +00:00
parent 7b729c49fa
commit 06101b6316
2 changed files with 18 additions and 4 deletions

View File

@@ -38,6 +38,10 @@ void mie_printer_print_op_arg(
b_stream_write_char(printer->p_stream, '%'); b_stream_write_char(printer->p_stream, '%');
} }
if (!arg_name) {
arg_name = "<NO-NAME>";
}
b_stream_write_string(printer->p_stream, arg_name, NULL); b_stream_write_string(printer->p_stream, arg_name, NULL);
if (!resolved if (!resolved
@@ -62,15 +66,20 @@ void mie_printer_print_op_successor(
b_stream_write_char(printer->p_stream, '^'); b_stream_write_char(printer->p_stream, '^');
bool resolved = false; bool resolved = false;
const char *name = NULL;
if (successor->s_flags & MIE_OP_F_SUCCESSOR_RESOLVED) { if (successor->s_flags & MIE_OP_F_SUCCESSOR_RESOLVED) {
b_stream_write_string( name = successor->s_block->b_name.n_str;
printer->p_stream, successor->s_block->b_name.n_str, NULL);
resolved = true; resolved = true;
} else { } else {
b_stream_write_string( name = successor->s_block_name;
printer->p_stream, successor->s_block_name, NULL);
} }
if (!name) {
name = "<NO-NAME>";
}
b_stream_write_string(printer->p_stream, name, NULL);
if (!resolved if (!resolved
&& MIE_TEST_FLAGS( && MIE_TEST_FLAGS(
printer->p_flags, MIE_PRINT_F_MARK_UNRESOLVED_ELEMENTS)) { printer->p_flags, MIE_PRINT_F_MARK_UNRESOLVED_ELEMENTS)) {

View File

@@ -12,6 +12,11 @@
void mie_printer_print_type(struct mie_printer *printer, const struct mie_type *type) void mie_printer_print_type(struct mie_printer *printer, const struct mie_type *type)
{ {
if (!type) {
b_stream_write_string(printer->p_stream, "<NULL-TYPE>", NULL);
return;
}
if (TYPE_HAS_PRINT_CALLBACK(type)) { if (TYPE_HAS_PRINT_CALLBACK(type)) {
type->ty_def->ty_print(type, printer); type->ty_def->ty_print(type, printer);
} else if (TYPE_IS_BUILTIN(type)) { } else if (TYPE_IS_BUILTIN(type)) {