Hi,
GET_NUM macro contained two statements, and caused double stringshare free
when used in "if" statement without brackets and condition evaluated as
false.
e/src/modules/battery/e_mod_udev.c:
222 if (!bat->design_charge) <-- here
223 GET_NUM(bat, design_charge, POWER_SUPPLY_CHARGE_FULL_DESIGN);
224 }
225 GET_NUM(bat, last_full_charge, POWER_SUPPLY_ENERGY_FULL);
226 if (!bat->last_full_charge) <-- here
227 GET_NUM(bat, last_full_charge, POWER_SUPPLY_CHARGE_FULL);
Second part of the macro executed unconditionally and called
eina_stringshare_del for the old value of variable "test".
Please see the patch attached.
--
Regards
Basil Gor
e/modules/battery: fix double stringshare free
GET_NUM macro contained two statements, and caused double stringshare free
when used in "if" statement without brackets and condition evaluated as
false.
e/src/modules/battery/e_mod_udev.c:
222 if (!bat->design_charge) <-- here
223 GET_NUM(bat, design_charge, POWER_SUPPLY_CHARGE_FULL_DESIGN);
224 }
225 GET_NUM(bat, last_full_charge, POWER_SUPPLY_ENERGY_FULL);
226 if (!bat->last_full_charge) <-- here
227 GET_NUM(bat, last_full_charge, POWER_SUPPLY_CHARGE_FULL);
Second part of the macro executed unconditionally and called
eina_stringshare_del for the old value of variable "test".
---
e/src/modules/battery/e_mod_udev.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/e/src/modules/battery/e_mod_udev.c
b/e/src/modules/battery/e_mod_udev.c
index 58b1b40..46baae5 100644
--- a/e/src/modules/battery/e_mod_udev.c
+++ b/e/src/modules/battery/e_mod_udev.c
@@ -184,13 +184,16 @@ _battery_udev_battery_update_poll(void *data)
return EINA_TRUE;
}
-#define GET_NUM(TYPE, VALUE, PROP) test =
eeze_udev_syspath_get_property(TYPE->udi, #PROP); \
+#define GET_NUM(TYPE, VALUE, PROP) \
do
\
- if (test)
\
- {
\
- TYPE->VALUE = strtod(test, NULL);
\
- eina_stringshare_del(test);
\
- }
\
+ {
\
+ test = eeze_udev_syspath_get_property(TYPE->udi, #PROP);
\
+ if (test)
\
+ {
\
+ TYPE->VALUE = strtod(test, NULL);
\
+ eina_stringshare_del(test);
\
+ }
\
+ }
\
while (0)
#define GET_STR(TYPE, VALUE, PROP) TYPE->VALUE =
eeze_udev_syspath_get_property(TYPE->udi, #PROP)
--
1.7.11.4
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel