diff options
author | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2007-09-05 08:19:42 +0000 |
---|---|---|
committer | khali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0> | 2007-09-05 08:19:42 +0000 |
commit | 5e09f769b18a022bfdbcd6aec51c22b73783dd91 (patch) | |
tree | 8a104ab3b3d2a9b9a9f1cc392cb7bbd6633e130f /lib/init.c | |
parent | 26443e935d429be9005e362a287263ce70705819 (diff) | |
download | lm-sensors-5e09f769b18a022bfdbcd6aec51c22b73783dd91.tar.gz |
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
Diffstat (limited to 'lib/init.c')
-rw-r--r-- | lib/init.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -51,13 +51,13 @@ static void free_chip_name(sensors_chip_name *name) free(name->path); } -static void free_chip_features(sensors_chip_feature *features) +static void free_chip_features(sensors_chip_features *features) { int i; - for (i = 0; features[i].data.name; i++) - free(features[i].data.name); - free(features); + for (i = 0; i < features->feature_count; i++) + free(features->feature[i].data.name); + free(features->feature); } static void free_bus(sensors_bus *bus) @@ -140,7 +140,7 @@ void sensors_cleanup(void) for (i = 0; i < sensors_proc_chips_count; i++) { free_chip_name(&sensors_proc_chips[i].chip); - free_chip_features(sensors_proc_chips[i].feature); + free_chip_features(&sensors_proc_chips[i]); } free(sensors_proc_chips); sensors_proc_chips = NULL; |