Summary:
The 'if' block should only be executed when the string contains the colon and
something else behind, but sscanf cannot be used in this case.
If the string contained no colon, the following line with strchr(s, ':')
returns NULL and everything explodes.
Test Plan: eo_debug -l now works for me without segfaulting.
Reviewers: bu5hm4n, zmike, devilhorns, q66
Subscribers: cedric, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D6347
s = getenv("EO_LIFECYCLE_DEBUG");
if ((s) && (s[0] != '\0'))
{
- int lvl = 1;
-
+ char *es;
+ int lvl = (int)strtol(s, &es, 10);
_eo_log_objs_level = EO_REF_OP_FREE;
- if (sscanf(s, "%d:%*s", &lvl) == 1)
+ if ((es != s) && (*es == ':'))
{
if (lvl >= 3)
{
EINA_LOG_DOM_DBG(_eo_log_objs_dom,
"will log new, free, ref and unref");
}
- s = strchr(s, ':') + 1;
+ s = es + 1;
}
if ((strcmp(s, "*") == 0) || (strcmp(s, "1") == 0))