mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
fixed bug where fwrite_blocks crashed the server
This commit is contained in:
parent
f86dad801f
commit
6f590c85f6
@ -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<char>(*addr++);
|
||||
*ptr++ = static_cast<char>(*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<short>(*addr++);
|
||||
*ptr++ = static_cast<short>(*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<int>(*addr++);
|
||||
*ptr++ = static_cast<int>(*addr++);
|
||||
size_t res = fwrite(a, sizeof(int), blocks, fp);
|
||||
delete [] a;
|
||||
return res;
|
||||
|
Loading…
Reference in New Issue
Block a user