parse: fix memory leak

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-06-14 22:26:52 +02:00
parent b695eea2eb
commit dd90a3bfab
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -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