summaryrefslogtreecommitdiffstats
path: root/chardev
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé2022-08-19 17:39:23 +0200
committerPeter Maydell2022-09-22 17:38:28 +0200
commitd34977d682e382fb2af83e6e6508e3b06d1a3cf2 (patch)
tree1810a0e6443afa85f03f6b7e839ae66a7fee4410 /chardev
parentchardev/baum: Use definitions to avoid dynamic stack allocation (diff)
downloadqemu-d34977d682e382fb2af83e6e6508e3b06d1a3cf2.tar.gz
qemu-d34977d682e382fb2af83e6e6508e3b06d1a3cf2.tar.xz
qemu-d34977d682e382fb2af83e6e6508e3b06d1a3cf2.zip
chardev/baum: Avoid dynamic stack allocation
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20220819153931.3147384-4-peter.maydell@linaro.org
Diffstat (limited to 'chardev')
-rw-r--r--chardev/baum.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/chardev/baum.c b/chardev/baum.c
index 6a210ffd81..0a0d12661a 100644
--- a/chardev/baum.c
+++ b/chardev/baum.c
@@ -299,7 +299,8 @@ static void baum_chr_accept_input(struct Chardev *chr)
static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len)
{
Chardev *chr = CHARDEV(baum);
- uint8_t io_buf[1 + 2 * len], *cur = io_buf;
+ g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len);
+ uint8_t *cur = io_buf;
int room;
*cur++ = ESC;
while (len--)