Invalid memory access
#1

Hi,

What scripting problems, can call this error?

Код:
[20:48:22] [debug] Run time error 4: "Array index out of bounds"
[20:48:22] [debug]  Accessing element at negative index -1
[20:48:22] [debug] AMX backtrace:
[20:48:22] [debug] #0 001e7f84 in public Streamer_OnPlayerDisconnect () from qer.amx
[20:48:22] [debug] #1 native CallLocalFunction () [080d2870] from samp03svr
[20:48:22] [debug] #2 00008f88 in ?? () from qer.amx
[20:48:22] [debug] #3 00002ee4 in public Itter_OnPlayerDisconnect () from qer.amx
[20:48:22] [debug] #4 native CallLocalFunction () [080d2870] from samp03svr
[20:48:22] [debug] #5 00000d34 in public OnPlayerDisconnect () from qer.amx
And how to fix it?
Reply
#2

Somewhere in your code you are trying to do this:

pawn Код:
array[-1]
Obviously you can't access the index -1, doing so will cause undefined behavior. It wont look like the above code because that would be a compile time error. It could be more similar to this:

pawn Код:
#define INVALID_SOMETHING -1

new index = INVALID_SOMETHING;
array[ index ];
Which will be a run time error.

And fix it by checking if the variable is '-1' before using it as an array index.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)