Raised This Month: $51 Target: $400
 12% 

index out of bounds problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 05-14-2006 , 16:01   index out of bounds problem
Reply With Quote #1

There is a function in amxbans that get index out of bounds after approx 23-24 iterations in the for loop

Here is the function
Code:
/* This is used by live ban on the webpages */ public cmdLst(id,level,cid) {     new players[32], inum, authid[32],name[32],ip[50]     get_players(players,inum)     console_print(id,"playerinfo")     for(new a = 0; a < inum; ++a)     {         get_user_ip(players[a],ip,49,1) // <:----------------------------- THIS LINE TRIGGERS THE ERROR         get_user_authid(players[a],authid,31)         get_user_name(players[a],name,31)         console_print(id,"#WM#%s#WMW#%s#WMW#%s#WMW#",name,authid,ip)     }     return PLUGIN_HANDLED }
Error
Code:
Run time error 4: index out of bounds
Thankful if anyone knows how to fix the problem.
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/
lantz69 is offline
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 05-14-2006 , 17:54  
Reply With Quote #2

Got help in a PM from Sean_D
Changed
Code:
for(new a = 0; a < inum; ++a)
to
Code:
for(new a = 0; a < inum; a++)

+Karma Sean
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/
lantz69 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 05-15-2006 , 05:09  
Reply With Quote #3

I can't believe that using ++var and var++ in the last block of the FOR loop can lead to the different behaviour.
for (init; condition; do) {body}
"do" is the standalone part and it's executed strictly after body and before condition, therefore it's should be not necessary if it's pre or post increment. :-/
VEN is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 05-15-2006 , 12:20  
Reply With Quote #4

If that fixes the problem, it's a code generation fault and should be reported to ITB Compuphase. I'll look at it today, maybe.
__________________
hello, i am pm
PM is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode