You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/01/18 18:27:48 UTC
[mynewt-core] branch master updated: hw/battery: Fix bounds checking
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new a110eb2 hw/battery: Fix bounds checking
a110eb2 is described below
commit a110eb2ec374164ebad6e3e25f311319e70a634e
Author: Casper Meijn <ca...@meijn.net>
AuthorDate: Sat Jan 16 22:01:15 2021 +0100
hw/battery: Fix bounds checking
Fixed two bugs related to bounds checking. These caused problems when
searching for a non-existing property.
---
hw/battery/src/battery.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/battery/src/battery.c b/hw/battery/src/battery.c
index c6d018c..892f2d2 100644
--- a/hw/battery/src/battery.c
+++ b/hw/battery/src/battery.c
@@ -228,7 +228,7 @@ find_driver_property(struct battery *bat, struct battery_driver *driver,
int i;
assert(driver);
- for (i = 0; driver->bd_property_count; ++i, ++prop) {
+ for (i = 0; i < driver->bd_property_count; ++i, ++prop) {
if (prop->bp_type == type && prop->bp_flags == flags) {
return prop;
}
@@ -248,8 +248,10 @@ find_hardware_property(struct battery *battery, struct battery_driver *driver,
res = find_driver_property(battery, driver, type, flags);
} else {
for (i = 0; res == NULL && i < BATTERY_DRIVERS_MAX; ++i) {
- res = find_driver_property(battery, battery->b_drivers[i],
- type, flags);
+ if (battery->b_drivers[i]) {
+ res = find_driver_property(battery, battery->b_drivers[i],
+ type, flags);
+ }
}
}
return res;