parse: fix memory leak

parent b695eea2
......@@ -68,7 +68,7 @@ int lxc_file_for_each_line_mmap(const char *file, lxc_file_cb callback,
void *data)
{
int fd;
char *buf, *line;
char *buf, *chop, *line;
struct stat st;
int ret = 0;
char *saveptr = NULL;
......@@ -94,7 +94,7 @@ int lxc_file_for_each_line_mmap(const char *file, lxc_file_cb callback,
return -1;
}
for (; (line = strtok_r(buf, "\n\0", &saveptr)); buf = NULL) {
for (chop = buf; (line = strtok_r(chop, "\n\0", &saveptr)); chop = NULL) {
ret = callback(line, data);
if (ret) {
/* Callback rv > 0 means stop here callback rv < 0 means
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment