[PATCH 1/5] Check type is not NULL before access
Zdenek Kabelac <[email protected]>
| Newsgroups | dev.linux.lists.lvm-devel |
|---|---|
| Message-ID | <fa6078b0a1e1a7eba4dc339f425715eada3ad826.1288097372.git.zkabelac@redhat.com> |
clang Logic error Dereference of null pointer Check type before dereference and report internal error in case it's undefined and return from the function. Signed-off-by: Zdenek Kabelac <[email protected]> --- libdm/libdm-report.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c index 7631e21..db24fed 100644 --- a/libdm/libdm-report.c +++ b/libdm/libdm-report.c @@ -273,6 +273,12 @@ static void _display_fields(struct dm_report *rh) log_warn("%*.*s", (int) strlen(desc) + 7, (int) strlen(desc) + 7, "-------------------------------------------------------------------------------"); + + if (!type) { + log_error(INTERNAL_ERROR "Type is not defined."); + return; + } + log_warn(" %sall%-*s - %s", type->prefix, (int) (id_len - 3 - strlen(type->prefix)), "", "All fields in this section."); -- 1.7.3.2