From be1194e4b46ef36c268fcd4915a8fa0411776ea9 Mon Sep 17 00:00:00 2001 From: Atemo Date: Tue, 13 Aug 2019 19:05:29 +0200 Subject: [PATCH] Empty message in announce script command (#4200) Added a check to fail silently when the message in the *announce script commands is "" --- src/map/clif.cpp | 8 ++++++++ src/map/intif.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index c3cb4a2b0e..2a4714d15a 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -6220,6 +6220,10 @@ void clif_displaymessage(const int fd, const char* mes) /// 009a .W .?B void clif_broadcast(struct block_list* bl, const char* mes, int len, int type, enum send_target target) { + nullpo_retv(mes); + if (len < 2) + return; + int lp = (type&BC_COLOR_MASK) ? 4 : 0; std::unique_ptr buf(new unsigned char[4+lp+len]); @@ -6266,6 +6270,10 @@ void clif_GlobalMessage(struct block_list* bl, const char* message, enum send_ta /// 01c3 .W .L .W .W .W .W .?B void clif_broadcast2(struct block_list* bl, const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, enum send_target target) { + nullpo_retv(mes); + if (len < 2) + return; + std::unique_ptr buf(new unsigned char[16+len]); WBUFW(buf.get(),0) = 0x1c3; diff --git a/src/map/intif.cpp b/src/map/intif.cpp index d8d69a8863..95071fc8dc 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -205,6 +205,10 @@ int intif_rename(struct map_session_data *sd, int type, char *name) */ int intif_broadcast(const char* mes, int len, int type) { + nullpo_ret(mes); + if (len < 2) + return 0; + int lp = (type|BC_COLOR_MASK) ? 4 : 0; // Send to the local players @@ -246,6 +250,10 @@ int intif_broadcast(const char* mes, int len, int type) */ int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY) { + nullpo_ret(mes); + if (len < 2) + return 0; + // Send to the local players clif_broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT);