From 9ed87aece7a60b19d978e78fc07f14514158d9eb Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Sun, 21 Mar 2010 13:59:45 +0000 Subject: [PATCH] Check parameters of function for NULL --- golded3/gelmsg.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/golded3/gelmsg.cpp b/golded3/gelmsg.cpp index c8a16ed..c9b12db 100644 --- a/golded3/gelmsg.cpp +++ b/golded3/gelmsg.cpp @@ -26,11 +26,16 @@ #include - // ------------------------------------------------------------------ void ResetMsg(GMsg* msg) { + if( msg == NULL ) + { + LOG.printf("! ResetMsg() is called with NULL pointer to msg." ); + PointerErrorExit(); + } + msg->link.reset(); throw_xfree(msg->references); @@ -50,7 +55,13 @@ void ResetMsg(GMsg* msg) // ------------------------------------------------------------------ -int Area::LoadHdr(GMsg* msg, uint32_t msgno, bool enable_recode) { +int Area::LoadHdr(GMsg* msg, uint32_t msgno, bool enable_recode) +{ + if( msg == NULL ) + { + LOG.printf("! Area::LoadHdr() is called with NULL pointer to msg." ); + return false; + } ResetMsg(msg); msg->msgno = msgno; @@ -89,7 +100,13 @@ int Area::LoadHdr(GMsg* msg, uint32_t msgno, bool enable_recode) { // ------------------------------------------------------------------ -int Area::LoadMsg(GMsg* msg, uint32_t msgno, int margin, int mode) { +int Area::LoadMsg(GMsg* msg, uint32_t msgno, int margin, int mode) +{ + if( msg == NULL ) + { + LOG.printf("! Area::LoadMsg() is called with NULL pointer to msg." ); + return false; + } ResetMsg(msg); msg->msgno = msgno; @@ -120,7 +137,13 @@ int Area::LoadMsg(GMsg* msg, uint32_t msgno, int margin, int mode) { // ------------------------------------------------------------------ -void Area::SaveHdr(int mode, GMsg* msg) { +void Area::SaveHdr(int mode, GMsg* msg) +{ + if( msg == NULL ) + { + LOG.printf("! Area::LoadMsg() is called with NULL pointer to msg." ); + PointerErrorExit(); + } // Translate softcr to configured char if (adat->usesoftcrxlat && EDIT->SoftCrXlat()) @@ -136,6 +159,4 @@ void Area::SaveHdr(int mode, GMsg* msg) { UpdateAreadata(); } - // ------------------------------------------------------------------ -