From 6f590c85f60ab3227166ad775eb5792bf2c7582e Mon Sep 17 00:00:00 2001 From: Christian Hammacher Date: Fri, 29 Jun 2007 21:46:24 +0000 Subject: [PATCH] fixed bug where fwrite_blocks crashed the server --- amxmodx/file.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/amxmodx/file.cpp b/amxmodx/file.cpp index 0dee9d87..412d8e37 100755 --- a/amxmodx/file.cpp +++ b/amxmodx/file.cpp @@ -383,8 +383,9 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params) case 1: { char *a = new char[blocks]; + char *ptr = a; while (btmp--) - *a++ = static_cast(*addr++); + *ptr++ = static_cast(*addr++); size_t res = fwrite(a, sizeof(char), blocks, fp); delete [] a; return res; @@ -392,8 +393,9 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params) case 2: { short *a = new short[blocks]; + short *ptr = a; while (btmp--) - *a++ = static_cast(*addr++); + *ptr++ = static_cast(*addr++); size_t res = fwrite(a, sizeof(short), blocks, fp); delete [] a; return res; @@ -401,8 +403,9 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params) case 4: { int *a = new int[blocks]; + int *ptr = a; while (btmp--) - *a++ = static_cast(*addr++); + *ptr++ = static_cast(*addr++); size_t res = fwrite(a, sizeof(int), blocks, fp); delete [] a; return res;