summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-12-08 12:03:09 +0000
committerTom Hacohen <tom@stosb.com>2015-12-08 12:47:46 +0000
commit6045f24446c55560a7ad9e7631f47bb00b739cf6 (patch)
treebe068df644c5c0476c974d019e6d09eeda3962cf
parent6936636edf0efcd77516066ed161ee1e7fc12b35 (diff)
Elm spinner: Fix potential null deref in decimal get function.
This whole code reeks. This generating and parsing strings as a value store is hacky and could use an overhaul. This just fixes the more obvious possible errors (that are maybe not even possible, just look possible). CID1339828 CID1339829
-rw-r--r--src/lib/elm_spinner.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/elm_spinner.c b/src/lib/elm_spinner.c
index 5fe0caa3f..019ad4d03 100644
--- a/src/lib/elm_spinner.c
+++ b/src/lib/elm_spinner.c
@@ -398,7 +398,7 @@ _entry_activated_cb(void *data,
398static int 398static int
399_decimal_points_get(const char *label) 399_decimal_points_get(const char *label)
400{ 400{
401 char result[2]; 401 char result[2] = "";
402 const char *start = strchr(label, '%'); 402 const char *start = strchr(label, '%');
403 403
404 while (start) 404 while (start)
@@ -406,14 +406,16 @@ _decimal_points_get(const char *label)
406 if (start[1] != '%') 406 if (start[1] != '%')
407 { 407 {
408 start = strchr(start, '.'); 408 start = strchr(start, '.');
409 start++; 409 if (start)
410 start++;
410 break; 411 break;
411 } 412 }
412 else 413 else
413 start = strchr(start + 2, '%'); 414 start = strchr(start + 2, '%');
414 } 415 }
415 416
416 sscanf(start, "%[^f]", result); 417 if (start)
418 sscanf(start, "%[^f]", result);
417 419
418 return atoi(result); 420 return atoi(result);
419} 421}