From 2cbe71c569e089803800a8080c134f45c82b6faa Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 11 Sep 2013 09:51:03 +0200 Subject: [PATCH] Fix possible crash when generating presence xml. --- coreapi/presence.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/coreapi/presence.c b/coreapi/presence.c index 16c8bdcd2..314946c4f 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -1528,8 +1528,11 @@ static int write_xml_presence_service(xmlTextWriterPtr writer, LinphonePresenceS err = xmlTextWriterWriteAttribute(writer, (const xmlChar *)"priority", (const xmlChar *)"0.8"); } if (err >= 0) { - const char *contact_str = service->contact; - if (contact_str == NULL) contact_str = contact; + const char *contact_str; + if ((service == NULL) || (service->contact == NULL)) + contact_str = contact; + else + contact_str = service->contact; err = xmlTextWriterWriteString(writer, (const xmlChar *)contact_str); } if (err >= 0) {