From e14b681d6e98e41a0f081ba129efda4a12b00697 Mon Sep 17 00:00:00 2001 From: mjentsch Date: Sun, 19 Jul 2015 15:07:27 +0200 Subject: [PATCH] Fix segfault --- tgp-msg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tgp-msg.c b/tgp-msg.c index 01bcfc2..1feda0b 100644 --- a/tgp-msg.c +++ b/tgp-msg.c @@ -443,8 +443,12 @@ void tgp_msg_recv (struct tgl_state *TLS, struct tgl_message *M) { return; } if (M->media.type == tgl_message_media_photo) { - C->done = FALSE; - tgl_do_load_photo (TLS, M->media.photo, tgp_msg_on_loaded_document, C); + + // there are messages with type media_photo, but without a photo element, buy why? + if (M->media.photo) { + C->done = FALSE; + tgl_do_load_photo (TLS, M->media.photo, tgp_msg_on_loaded_document, C); + } } if (M->media.type == tgl_message_media_document_encr && M->media.encr_document->flags & TGLDF_IMAGE &&