Skip to content

Fix empty warnings causing crashes #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions source/compiler/sc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,16 +1538,14 @@ static int command(void)
#endif
case tpERROR:
case tpWARNING:
while (*lptr<=' ' && *lptr!='\0')
lptr++;
while (*lptr<=' ' && *lptr!='\0')
lptr++;
if (!SKIPPING) {
char *usermsg=strdupwithouta((const char *)lptr);
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 */
Expand Down
6 changes: 6 additions & 0 deletions source/compiler/tests/empty_warning_crash_gh_339.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
'test_type': 'output_check',
'errors': """
empty_warning_crash_gh_339.pwn(1) : warning 237: user warning:
"""
}
3 changes: 3 additions & 0 deletions source/compiler/tests/empty_warning_crash_gh_339.pwn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#warning

main () {}