summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Friis <peavey@placid.dk>2008-04-10 17:15:31 +0000
committerDennis Friis <peavey@placid.dk>2008-04-10 17:15:31 +0000
commit80611a4186d4aa4fda481055b98e98a910c0778b (patch)
tree33fec83b5b521546ced33976b802863f78a6e7f2 /src
parent7a0dcb7a9845d0fe34a745c04549434731d2adb0 (diff)
downloadtmwa-80611a4186d4aa4fda481055b98e98a910c0778b.tar.gz
tmwa-80611a4186d4aa4fda481055b98e98a910c0778b.tar.bz2
tmwa-80611a4186d4aa4fda481055b98e98a910c0778b.tar.xz
tmwa-80611a4186d4aa4fda481055b98e98a910c0778b.zip
revert rev 17
Diffstat (limited to 'src')
-rw-r--r--src/map/intif.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/map/intif.c b/src/map/intif.c
index 4464dc5..ace0187 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -584,20 +584,22 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 <packet_len>.w <wispname>.24B
int i, min_gm_level;
struct map_session_data *pl_sd;
char Wisp_name[24];
- char *message = malloc((RFIFOW(fd,2) - 30));
+ char mbuf[255];
+ char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) malloc((RFIFOW(fd,2) - 30)) : mbuf;
min_gm_level = (int)RFIFOW(fd,28);
memcpy(Wisp_name, RFIFOP(fd,4), 24);
Wisp_name[23] = '\0';
- memcpy(message, RFIFOP(fd,30), (RFIFOW(fd,2) - 30));
- message[RFIFOW(fd,2) - 31] = '\0';
+ memcpy(message, RFIFOP(fd,30), RFIFOW(fd,2) - 30);
+ message[sizeof(message) - 1] = '\0';
// information is sended to all online GM
for (i = 0; i < fd_max; i++)
if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth)
if (pc_isGM(pl_sd) >= min_gm_level)
clif_wis_message(i, Wisp_name, message, strlen(message) + 1);
- free(message);
+ if (message != mbuf)
+ free(message);
return 0;
}