mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-12-04 21:58:18 +00:00
Store the feature list length separately instead of null-terminating
the list. This make it possible to check for out-of-bound indexes without walking the entire list, so that direct look-ups are safer. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4760 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
7975800ac1
commit
23f4274010
4 files changed
+15
-10
No files matched your search
+3
-2
@@ -64,7 +64,7 @@ int get_type_scaling(int type)
|
||||
static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
struct sysfs_device *sysdir)
|
||||
{
|
||||
int i, type, fnum = 1;
|
||||
int i, type, fnum = 0;
|
||||
struct sysfs_attribute *attr;
|
||||
struct dlist *attrs;
|
||||
sensors_chip_feature *features;
|
||||
@@ -160,7 +160,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
fnum++;
|
||||
}
|
||||
|
||||
if (fnum == 1) { /* No feature */
|
||||
if (!fnum) { /* No feature */
|
||||
chip->feature = NULL;
|
||||
goto exit_free;
|
||||
}
|
||||
@@ -194,6 +194,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
|
||||
}
|
||||
|
||||
chip->feature = dyn_features;
|
||||
chip->feature_count = fnum;
|
||||
|
||||
exit_free:
|
||||
free(features);
|
||||
|
||||
Reference in new issue
Block a user