diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2017-03-10 19:42:31 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2017-03-10 23:25:31 +0000 |
commit | b851e45e0a64c01ae77468aa7bc851715b31613b (patch) | |
tree | 018a2dc2ce75ed075e37788e1b8502126aa75f66 /Source/CParse/parser.y | |
parent | 4f235027f48b52d7dca4ed019a0eb11c0e483ada (diff) | |
download | swig-b851e45e0a64c01ae77468aa7bc851715b31613b.tar.gz |
Fix seg fault for global declarations declared erroneously without a name
Diffstat (limited to 'Source/CParse/parser.y')
-rw-r--r-- | Source/CParse/parser.y | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 1e8208ce8..69dce5534 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3040,29 +3040,34 @@ c_decl : storage_class type declarator initializer c_decl_tail { Setattr($$,"bitfield", $4.bitfield); } - /* Look for "::" declarations (ignored) */ - if (Strstr($3.id,"::")) { - /* This is a special case. If the scope name of the declaration exactly - matches that of the declaration, then we will allow it. Otherwise, delete. */ - String *p = Swig_scopename_prefix($3.id); - if (p) { - if ((Namespaceprefix && Strcmp(p, Namespaceprefix) == 0) || - (Classprefix && Strcmp(p, Classprefix) == 0)) { - String *lstr = Swig_scopename_last($3.id); - Setattr($$,"name",lstr); - Delete(lstr); - set_nextSibling($$,$5); + if ($3.id) { + /* Look for "::" declarations (ignored) */ + if (Strstr($3.id, "::")) { + /* This is a special case. If the scope name of the declaration exactly + matches that of the declaration, then we will allow it. Otherwise, delete. */ + String *p = Swig_scopename_prefix($3.id); + if (p) { + if ((Namespaceprefix && Strcmp(p, Namespaceprefix) == 0) || + (Classprefix && Strcmp(p, Classprefix) == 0)) { + String *lstr = Swig_scopename_last($3.id); + Setattr($$, "name", lstr); + Delete(lstr); + set_nextSibling($$, $5); + } else { + Delete($$); + $$ = $5; + } + Delete(p); } else { Delete($$); $$ = $5; } - Delete(p); } else { - Delete($$); - $$ = $5; + set_nextSibling($$, $5); } } else { - set_nextSibling($$,$5); + Swig_error(cparse_file, cparse_line, "Missing symbol name for global declaration\n"); + $$ = 0; } } /* Alternate function syntax introduced in C++11: |