From 32415c60cc8f24f05a497a4511610039b043286b Mon Sep 17 00:00:00 2001
From: Simon Chopin <simon.chopin@canonical.com>
Date: Wed, 1 Dec 2021 18:25:21 +0100
Subject: [PATCH] queries: fix partially-uninitialized struct
Forwarded: https://github.com/vysheng/tgl/pull/150

The `x` instance wasn't initialized properly, which led to undefined
behaviour in _tgl_do_send_photo when copying its content to t->avatar.

This patch fixes that by using the C struct initializer syntax, which
implicitly sets all missing fields to 0.

Note that this UB triggers a compilation warning when compiling with
recent GCC versions in -O3.
---
 queries.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/queries.c b/queries.c
index 5c1c528..72e8dbd 100644
--- a/queries.c
+++ b/queries.c
@@ -2183,8 +2183,7 @@ void tgl_do_send_document (struct tgl_state *TLS, tgl_peer_id_t to_id, const cha
       flags |= TGLDF_AUDIO;
     }
   }
-  tgl_peer_id_t x;
-  x.peer_id = 0;
+  tgl_peer_id_t x = { .peer_id=0 };
   _tgl_do_send_photo (TLS, to_id, file_name, x, 100, 100, 100, 0, 0, caption, caption_len, flags, callback, callback_extra);
 }
 
-- 
2.32.0

