From b95e8e2574029bfbeabddd1f8df99906a4f695e6 Mon Sep 17 00:00:00 2001 From: Burt P Date: Sun, 27 Aug 2017 12:39:57 -0500 Subject: dmi: check for null from dmi_get_str() in dmi_chassis_type_str() Fix a crash when there is no DMI available. Signed-off-by: Burt P --- hardinfo/dmi_util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'hardinfo/dmi_util.c') diff --git a/hardinfo/dmi_util.c b/hardinfo/dmi_util.c index 5083c3c8..28b2c197 100644 --- a/hardinfo/dmi_util.c +++ b/hardinfo/dmi_util.c @@ -140,8 +140,11 @@ char *dmi_chassis_type_str(int chassis_type, gboolean with_val) { if (chassis_type <= 0) { gchar *chassis = dmi_get_str("chassis-type"); - chassis_type = atoi(chassis); - g_free(chassis); + if (chassis) { + chassis_type = atoi(chassis); + g_free(chassis); + } else + chassis_type = -1; } if (chassis_type >= 0 && chassis_type < G_N_ELEMENTS(types)) { -- cgit v1.2.3