mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-03 04:24:00 +00:00
parse: fix memory leak
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
parent
b695eea2eb
commit
dd90a3bfab
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user