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

Awkward behavior after GetArray (memory corruption?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ttasdasda
Member
Join Date: Apr 2014
Old 11-07-2018 , 05:12   Awkward behavior after GetArray (memory corruption?)
Reply With Quote #1

I have a very weird problem. Two local variables suddenly change their value in the middle of a cycle right after I call GetArray.

Code:
for (int i = index; i < len; i++)
    {
        int counter = i;
        int data[3];
        PrintToChatAll("i = %i | index = %i | counter = %i | len = %i", i, index, counter, len);
        reco.GetArray(counter, data);
        PrintToChatAll("i = %i | counter = %i", i, counter);
    }


I have tried updating MM and running the code on both SM 1.9 and 1.10. I'm pretty sure it used to work just fine half a year ago or so.
It does NOT seem to happen in another plugin of mine that uses the exact same ArrayList. In fact, copy-pasting the code from that other plugin leads to the same error.
ttasdasda is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-07-2018 , 06:53   Re: Awkward behavior after GetArray (memory corruption?)
Reply With Quote #2

You should also provide how you initialize reco.
__________________

Last edited by klippy; 11-07-2018 at 06:56.
klippy is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-07-2018 , 17:33   Re: Awkward behavior after GetArray (memory corruption?)
Reply With Quote #3

Isn't a bad idea to declare variables inside cycle?
Check "data" buf. size against the block size you declared arraylist with.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 15:46.


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