From 54165a84754ce51c88cabcc585647ef28b6ee1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sun, 12 May 2019 14:16:36 +0200 Subject: [PATCH] conv-settings-dialog: harden number2eng function against null pointer --- widgets/conv-settings-dialog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/widgets/conv-settings-dialog.c b/widgets/conv-settings-dialog.c index 7884cb2..b502bc5 100644 --- a/widgets/conv-settings-dialog.c +++ b/widgets/conv-settings-dialog.c @@ -191,6 +191,10 @@ static double convert_number_to_engineering(double input, const char **out_prefi 1E2, 1E3, 1E6, 1E9, 1E12, 1E15, 1E18, 1E21, 1E24}; const int prefix_count = (int)(sizeof(prefixes)/sizeof(char *)); + /* If pointer is invalid, return NaN */ + if (!out_prefix) + return 0.0 / 0.0; + /* Start with the 2nd smallest prefix */ for (idx = 1; idx < prefix_count; idx++) { if (input < scale[idx]) {