Fix gcc-11 error "directive argument is null"

mdbtools triggered
In function ‘printf’,
    inlined from ‘mdb_dump_catalog’ at catalog.c:195:4:
/usr/include/powerpc64le-linux-gnu/bits/stdio2.h:112:10:
error: ‘%-12s’ directive argument is null [-Werror=format-overflow=]
  112 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());

This is due to mdb_get_objtype_string potentially returning NULL
which isn't allowed anymore as it would cause a segfault on the latter
print.

Fixes: #352

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
This commit is contained in:
Christian Ehrhardt 2021-09-30 09:50:19 +02:00 committed by Evan Miller
parent 5946750058
commit 22c379a611

View File

@ -193,7 +193,7 @@ mdb_dump_catalog(MdbHandle *mdb, int obj_type)
entry = g_ptr_array_index(mdb->catalog,i);
if (obj_type==MDB_ANY || entry->object_type==obj_type) {
printf("Type: %-12s Name: %-48s Page: %06lx\n",
mdb_get_objtype_string(entry->object_type),
mdb_get_objtype_string(entry->object_type) ?: "Unknown",
entry->object_name,
entry->table_pg);
}