2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 22:35:33 +00:00

proc_parce: Fix assignment of ns_mountpoint

realloc() may move a memory chunk in case of shrink.

v4: New
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Kirill Tkhai
2016-07-20 13:13:03 +03:00
committed by Pavel Emelyanov
parent 9c7a234b3e
commit 227ffd3e40

View File

@@ -1285,7 +1285,6 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
new->mountpoint = xmalloc(PATH_MAX); new->mountpoint = xmalloc(PATH_MAX);
if (new->mountpoint == NULL) if (new->mountpoint == NULL)
goto err; goto err;
new->ns_mountpoint = new->mountpoint;
new->mountpoint[0] = '.'; new->mountpoint[0] = '.';
ret = sscanf(str, "%i %i %u:%u %ms %s %ms %n", ret = sscanf(str, "%i %i %u:%u %ms %s %ms %n",
@@ -1308,6 +1307,7 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
new->mountpoint = xrealloc(new->mountpoint, strlen(new->mountpoint) + 1); new->mountpoint = xrealloc(new->mountpoint, strlen(new->mountpoint) + 1);
if (!new->mountpoint) if (!new->mountpoint)
goto err; goto err;
new->ns_mountpoint = new->mountpoint;
new->s_dev = new->s_dev_rt = MKKDEV(kmaj, kmin); new->s_dev = new->s_dev_rt = MKKDEV(kmaj, kmin);
new->flags = 0; new->flags = 0;