linux-user: fix realloc size of target_fd_trans.
PATCH 1/1 linux-user: fix realloc size of target_fd_trans.
target_fd_trans is an array of "TargetFdTrans *": compute size accordingly. Use g_renew() as proposed by Paolo.
Reported-by Paolo Bonzini <[email protected]>
Signed-off-by Laurent Vivier <[email protected]>
--- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
linux-user/syscall.c +2 -2
@@ -330,8 +330,8 @@ static void fd_trans_register(int fd, TargetFdTrans *trans)if (fd >= target_fd_max) { oldmax = target_fd_max; target_fd_max = ((fd >>6 ) +1 ) <<6 ;/* by slice of 64 entries */ - target_fd_trans =g_realloc (target_fd_trans, - target_fd_max *sizeof (TargetFdTrans)); + target_fd_trans = g_renew(TargetFdTrans *, + target_fd_trans, target_fd_max);memset ((void *)(target_fd_trans + oldmax),0 , (target_fd_max - oldmax) *sizeof (TargetFdTrans *)); }
Signature · 1 line
2.5.0
Ping ?
Quoted 25 lines · Laurent Vivier
target_fd_transis an array of "TargetFdTrans *": compute size accordingly. Useg_renew()as proposed by Paolo.Reported-by Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)linux-user/syscall.c +2
-2@@ -330,8 +330,8 @@ static void fd_trans_register(int fd, TargetFdTrans *trans)if (fd >= target_fd_max) { oldmax = target_fd_max; target_fd_max = ((fd >>6 ) +1 ) <<6 ;/* by slice of 64 entries */ - target_fd_trans =g_realloc (target_fd_trans, - target_fd_max *sizeof (TargetFdTrans)); + target_fd_trans = g_renew(TargetFdTrans *, + target_fd_trans, target_fd_max);memset ((void *)(target_fd_trans + oldmax),0 , (target_fd_max - oldmax) *sizeof (TargetFdTrans *)); }
Riku Voipio
AppliedHi,
Applied to linux-user, thanks
Riku
Quoted 11 lines · Laurent Vivier
Ping ?
Quoted 6 lines · Laurent Vivier
target_fd_transis an array of "TargetFdTrans *": compute size accordingly. Useg_renew()as proposed by Paolo.Reported-by Paolo Bonzini <[email protected]>Signed-off-by Laurent Vivier <[email protected]>--- ...