Fixes issues w/battery and batman living together

Summary:
The problems were that both sysctl implementations defined public accessable fields named bat.

The static definition moves into the file scopes.

The E_FREE calls are fixing a use after free.

Reviewers: zmike!, bu5hm4n

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D4629
This commit is contained in:
Al Poole 2017-01-29 12:47:01 +01:00 committed by Marcel Hollerbach
parent abd60cca9a
commit 55a7d4feed
2 changed files with 11 additions and 11 deletions

View File

@ -18,8 +18,8 @@ extern Eina_List *device_batteries;
extern Eina_List *device_ac_adapters; extern Eina_List *device_ac_adapters;
extern double init_time; extern double init_time;
Ac_Adapter *ac = NULL; static Ac_Adapter *ac = NULL;
Battery *bat = NULL; static Battery *bat = NULL;
int int
_battery_sysctl_start(void) _battery_sysctl_start(void)
@ -138,8 +138,8 @@ _battery_sysctl_stop(void)
if (ac) if (ac)
{ {
eina_stringshare_del(ac->udi); eina_stringshare_del(ac->udi);
free(ac->mib); E_FREE(ac->mib);
free(ac); E_FREE(ac);
} }
if (bat) if (bat)
@ -150,12 +150,12 @@ _battery_sysctl_stop(void)
eina_stringshare_del(bat->vendor); eina_stringshare_del(bat->vendor);
ecore_poller_del(bat->poll); ecore_poller_del(bat->poll);
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
free(bat->mib_state); E_FREE(bat->mib_state);
free(bat->mib_time); E_FREE(bat->mib_time);
free(bat->mib_units); E_FREE(bat->mib_units);
#endif #endif
free(bat->mib); E_FREE(bat->mib);
free(bat); E_FREE(bat);
} }
} }

View File

@ -18,8 +18,8 @@ extern Eina_List *batman_device_batteries;
extern Eina_List *batman_device_ac_adapters; extern Eina_List *batman_device_ac_adapters;
extern double batman_init_time; extern double batman_init_time;
Ac_Adapter *ac = NULL; static Ac_Adapter *ac = NULL;
Battery *bat = NULL; static Battery *bat = NULL;
int int
_batman_sysctl_start(Instance *inst) _batman_sysctl_start(Instance *inst)