Attention is currently required from: Zheng Bao.

Bao Zheng would like Zheng Bao to review this change.

View Change

amdfwtool: Clear struct match before regular expression matching

If it is not cleared and the number of strings is fewer than last
iteration, the match[3] will keep the last value.

Change-Id: If14e0923fbb1648d83784eb5dc1411c93227db5a
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>
---
M util/amdfwtool/data_parse.c
1 file changed, 2 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/62482/1
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c
index a6b73ee..7f9816b 100644
--- a/util/amdfwtool/data_parse.c
+++ b/util/amdfwtool/data_parse.c
@@ -428,10 +428,12 @@
return OK;
}

+#define N_MATCHES 4
static int is_valid_entry(char *oneline, regmatch_t *match)
{
int retval;

+ memset (match, 0, sizeof(regmatch_t) * N_MATCHES);
if (regexec(&entries_line_expr, oneline, 3, match, 0) == 0) {
oneline[match[1].rm_eo] = '\0';
oneline[match[2].rm_eo] = '\0';
@@ -467,7 +469,6 @@
return retval;
}

-#define N_MATCHES 4
/*
return value:
0: The config file can not be parsed correctly.

To view, visit change 62482. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If14e0923fbb1648d83784eb5dc1411c93227db5a
Gerrit-Change-Number: 62482
Gerrit-PatchSet: 1
Gerrit-Owner: Bao Zheng <fishbaozi@gmail.com>
Gerrit-Reviewer: Zheng Bao
Gerrit-Attention: Zheng Bao
Gerrit-MessageType: newchange