From fb42b0d7cde6af0e10926682eaefe0e98aa8be33 Mon Sep 17 00:00:00 2001 From: Dastgir Date: Sat, 16 Jan 2016 12:23:12 +0530 Subject: Fixes crash with @send --- src/map/atcommand.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e223f698c..e2c9f1720 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -260,24 +260,28 @@ ACMD(send) if (type >= MIN_PACKET_DB && type <= MAX_PACKET_DB) { int off = 2; + if (clif->packet(type) == NULL) { + // unknown packet - ERROR + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x + clif->message(fd, atcmd_output); + return false; + } + if (len) { // show packet length safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d clif->message(fd, atcmd_output); return true; } - + len = clif->packet(type)->len; - if (len == 0) { - // unknown packet - ERROR - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x - clif->message(fd, atcmd_output); - return false; - } else if (len == -1) { + + if (len == -1) { // dynamic packet len = SHRT_MAX-4; // maximum length off = 4; } + WFIFOHEAD(sd->fd, len); WFIFOW(sd->fd,0)=TOW(type); -- cgit v1.2.3-60-g2f50