summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDastgir <dastgirpojee@rocketmail.com>2016-01-16 12:23:12 +0530
committerDastgir <dastgirpojee@rocketmail.com>2016-01-16 12:23:12 +0530
commitfb42b0d7cde6af0e10926682eaefe0e98aa8be33 (patch)
treef6549584459c6bd9134a8cbead15383997472f94
parent9e48e2aebd5777179bd2fc2f45a58f8ad17b1373 (diff)
downloadhercules-fb42b0d7cde6af0e10926682eaefe0e98aa8be33.tar.gz
hercules-fb42b0d7cde6af0e10926682eaefe0e98aa8be33.tar.bz2
hercules-fb42b0d7cde6af0e10926682eaefe0e98aa8be33.tar.xz
hercules-fb42b0d7cde6af0e10926682eaefe0e98aa8be33.zip
Fixes crash with @send
-rw-r--r--src/map/atcommand.c18
1 files changed, 11 insertions, 7 deletions
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);