From 1f962bd0894d0bd58cf312757c9ad5721158a79d Mon Sep 17 00:00:00 2001 From: Mehturt Date: Sat, 8 Dec 2007 02:03:53 +0100 Subject: [PATCH] Fixed bug #47 Fixed bug which made centerim crash when built with libotr support. This is a quick workaround until we refactor some code --- src/centermain.cc | 8 ++++++++ src/imotr.cc | 11 ++++++++--- src/imotr.h | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/centermain.cc b/src/centermain.cc index 5522a1a..6e4625f 100644 --- a/src/centermain.cc +++ b/src/centermain.cc @@ -29,6 +29,10 @@ #include "icqmlist.h" #include "icqgroups.h" +#ifdef HAVE_LIBOTR +#include "imotr.h" +#endif + centerim cicq; icqconf conf; icqcontacts clist; @@ -58,6 +62,10 @@ int main(int argc, char **argv) { #endif conf.commandline(argc, argv); +#ifdef HAVE_LIBOTR + otr.init(); +#endif + cicq.exec(); } catch(exception e) { diff --git a/src/imotr.cc b/src/imotr.cc index 62d5c3c..afeecf6 100644 --- a/src/imotr.cc +++ b/src/imotr.cc @@ -257,8 +257,7 @@ static OtrlMessageAppOps ui_ops = - -imotr::imotr() +void imotr::init() { OTRL_INIT; // Initialize the OTR library @@ -270,9 +269,15 @@ imotr::imotr() } +imotr::imotr() + : userstate(0) +{ +} + imotr::~imotr() { - otrl_userstate_free(userstate); + if (0 != userstate) + otrl_userstate_free(userstate); } diff --git a/src/imotr.h b/src/imotr.h index 41d493b..cf98e79 100644 --- a/src/imotr.h +++ b/src/imotr.h @@ -48,6 +48,8 @@ class imotr { imotr(); ~imotr(); + + void init(); }; extern imotr otr; -- 2.11.4.GIT