dmi.c: Duplicate returned strings because they are meant to be freed
Without this patch dmi_shutdown calls free() on read-only strings.
Corresponding to flashrom svn r1849.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
diff --git a/dmi.c b/dmi.c
index 1b12096..a7a9a61 100644
--- a/dmi.c
+++ b/dmi.c
@@ -120,18 +120,18 @@
size_t i, len;
if (string_id == 0)
- return "Not Specified";
+ return strdup("Not Specified");
while (string_id > 1 && string_id--) {
if (buf >= limit) {
msg_perr("DMI table is broken (string portion out of bounds)!\n");
- return "<OUT OF BOUNDS>";
+ return strdup("<OUT OF BOUNDS>");
}
buf += strnlen(buf, limit - buf) + 1;
}
if (!*buf) /* as long as the current byte we're on isn't null */
- return "<BAD INDEX>";
+ return strdup("<BAD INDEX>");
len = strnlen(buf, limit - buf);
char *newbuf = malloc(len + 1);