summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--dmi.c14
2 files changed, 8 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 81adf67..9b09d9a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
- do not display any warning when driver field is empty in
/proc/bus/usb/devices (#53412)
+- fix freed memory usage in criteria_from_dmidecode and entries_matching_criteria
+- fix const warnings in dmi.c
Version 0.8.4 - 25 June 2009, Pascal Terjan
diff --git a/dmi.c b/dmi.c
index d316ed2..b927994 100644
--- a/dmi.c
+++ b/dmi.c
@@ -79,7 +79,7 @@ static char *get_after_colon(char *s) {
} else return NULL;
}
-static struct category *lookup_category(const char *cat_name) {
+static const struct category *lookup_category(const char *cat_name) {
int i;
for (i = 0; i < nb_categories; i++)
if (streq(categories[i].cat_name, cat_name))
@@ -87,7 +87,7 @@ static struct category *lookup_category(const char *cat_name) {
return NULL;
}
-static int lookup_field(struct category *category, const char *field_name) {
+static int lookup_field(const struct category *category, const char *field_name) {
unsigned int i;
for (i = 0; i < category->nb_fields; i++)
if (streq(category->fields[i], field_name))
@@ -108,9 +108,7 @@ static struct criteria criteria_from_dmidecode(void) {
FILE *f;
char buf[BUF_SIZE];
- struct criteria r;
-
- r.nb = 0;
+ struct criteria r = {0, NULL};
if (!(f = dmidecode_file ? fopen(dmidecode_file, "r") : popen("dmidecode", "r"))) {
perror("dmidecode");
@@ -119,7 +117,7 @@ static struct criteria criteria_from_dmidecode(void) {
r.criteria = malloc(sizeof(*r.criteria) * MAX_DEVICES);
- struct category *category = NULL;
+ const struct category *category = NULL;
/* dmidecode output is less indented as of 2.7 */
int tab_level = 1;
@@ -155,7 +153,7 @@ static struct criteria criteria_from_dmidecode(void) {
r.nb = 0;
return r;
}
- realloc(r.criteria, sizeof(*r.criteria) * r.nb);
+ r.criteria = realloc(r.criteria, sizeof(*r.criteria) * r.nb);
return r;
}
@@ -263,7 +261,7 @@ static struct dmi_entries entries_matching_criteria(struct criteria criteria) {
foreach_indent(0, ifree(constraints[i]));
fh_close(&f);
- realloc(r.entries, sizeof(*r.entries) * r.nb);
+ r.entries = realloc(r.entries, sizeof(*r.entries) * r.nb);
return r;
}