diff mbox series

dict: use reentrant version for strtok

Message ID 20181114153612.15952-1-sbabic@denx.de
State Accepted
Headers show
Series dict: use reentrant version for strtok | expand

Commit Message

Stefano Babic Nov. 14, 2018, 3:36 p.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/swupdate_dict.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/corelib/swupdate_dict.c b/corelib/swupdate_dict.c
index a5f14db..5970c55 100644
--- a/corelib/swupdate_dict.c
+++ b/corelib/swupdate_dict.c
@@ -177,6 +177,7 @@  int dict_parse_script(struct dict *dictionary, const char *script)
 	int ret = 0;
 	char *line = NULL, *key = NULL, *value = NULL;
 	size_t len = 0;
+	char *saveptr;
 
 	/* open script generated during sw-description parsing */
 	fp = fopen(script, "rb");
@@ -189,8 +190,8 @@  int dict_parse_script(struct dict *dictionary, const char *script)
 	/* load  key-value pairs from script into dictionary */
 
 	while ((getline(&line, &len, fp)) != -1) {
-		key = strtok(line, " \t\n");
-		value = strtok(NULL, "\t\n");
+		key = strtok_r(line, " \t\n", &saveptr);
+		value = strtok_r(NULL, "\t\n", &saveptr);
 		if (value != NULL && key != NULL) {
 			ret = dict_set_value(dictionary, key, value);
 			if (ret) {