4 Commits

Author SHA1 Message Date
Zeex
b54729c03c Fix crash with long function names
This fixes a buffer overrun introduced by commit eba8474294c1c106dd6e4f62a73160798f16458d.

The crash happens in do_call() when a function name was longer than
the max. allowed (sNAMEMAX) because of the leading '.' (dot) inserted
in command().

--------- test code --------

#include <a_samp>

OverlyLongFunctionNameYouCantEvenBotherToRead() {
	print("hey");
}

main() {
	OverlyLongFunctionNameYouCantEvenBotherToRead();
}

----- end of test code -----
2014-04-02 22:37:02 +07:00
Zeex
80eceb586d Fix compile crash on unknown assembly instruction
Make the assembler fail with a fatal error 104 "invalid assembler instruction"
if met an unknown instruction. It won't tell a correct line number though.
2014-01-04 16:00:52 +07:00
Zeex
eba8474294 Fix generation of function addresses in #emit code
This fixes a bug where the compiler generated incorrect addresses for
functions in #emit code if they were defined after the point of use.

For example, you couldn't reliably get the address of a function with
"#emit CONST.pri XXX" unless you make sure that XXX is defined before
the function in which you have you are referencing it.

Now the resolution of the function's address is deferred until assembling
phase (as with CALL), and the assembler is guaranteed to see all symbols
with their final addresses. To distinguish between functions and numeric
operands I added a '.' (period) in front of function names for both #emit
and normal calls.

See also 5) here: http://forum.sa-mp.com/showthread.php?t=355877

--------- test code --------

#include <a_samp> // DO NOT REMOVE THIS

main() {
	#emit const.pri foo
}

stock foo() {
	printf("Hello, World!");
}

----- end of test code -----
2014-01-03 09:14:06 +07:00
Zeex
766b96bcf3 Lower case directory names 2013-09-19 13:06:46 +07:00