Fix crash when #pragma deprecated message is empty

Fixes #283.
This commit is contained in:
Zeex 2018-02-08 07:39:07 +06:00
parent f34aa7d9b7
commit 73b64e141f
3 changed files with 12 additions and 1 deletions

View File

@ -1119,7 +1119,7 @@ static int command(void)
if (pc_deprecate!=NULL) {
char *ptr=pc_deprecate+strlen(pc_deprecate)-1;
/* remove trailing whitespace */
while (*ptr<= ' ')
while (ptr>=pc_deprecate && *ptr<= ' ')
*ptr--='\0';
} else {
error(103); /* insufficient memory */

View File

@ -40,6 +40,11 @@ set_tests_properties(unused_symbol_line_gh_252 PROPERTIES PASS_REGULAR_EXPRESSIO
.*\\.pwn\\(1\\) : warning 203: symbol is never used: \\\"x\\\"
")
add_compiler_test(gh_283 ${CMAKE_CURRENT_SOURCE_DIR}/gh_283.pwn)
set_tests_properties(gh_283 PROPERTIES PASS_REGULAR_EXPRESSION "\
.*\\.pwn\\(5\\) : warning 234: function is deprecated \\(symbol \"print\"\\)\
")
# Crashers
#
# These tests simply check that the compiler doesn't crash.

View File

@ -0,0 +1,6 @@
#pragma deprecated
native print(const string[]);
main() {
print("Hello World");
}