diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index 821f2a80..3398c59a 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -1538,8 +1538,6 @@ static int command(void) #endif case tpERROR: case tpWARNING: - while (*lptr<=' ' && *lptr!='\0') - lptr++; while (*lptr<=' ' && *lptr!='\0') lptr++; if (!SKIPPING) { @@ -1547,7 +1545,7 @@ static int command(void) if (usermsg!=NULL) { char *ptr=usermsg+strlen(usermsg)-1; /* remove trailing whitespace and newlines */ - while (*ptr<=' ') + while (ptr >= usermsg && *ptr<=' ') *ptr--='\0'; if (tok==tpERROR) error(111,usermsg); /* user error */ diff --git a/source/compiler/tests/empty_warning_crash_gh_339.meta b/source/compiler/tests/empty_warning_crash_gh_339.meta new file mode 100644 index 00000000..4a36e685 --- /dev/null +++ b/source/compiler/tests/empty_warning_crash_gh_339.meta @@ -0,0 +1,6 @@ +{ + 'test_type': 'output_check', + 'errors': """ +empty_warning_crash_gh_339.pwn(1) : warning 237: user warning: +""" +} diff --git a/source/compiler/tests/empty_warning_crash_gh_339.pwn b/source/compiler/tests/empty_warning_crash_gh_339.pwn new file mode 100644 index 00000000..fe5b88e2 --- /dev/null +++ b/source/compiler/tests/empty_warning_crash_gh_339.pwn @@ -0,0 +1,3 @@ +#warning + +main () {} \ No newline at end of file