Skip to content

Commit

Permalink
Fix seg fault parsing unterminated raw string literals
Browse files Browse the repository at this point in the history
  • Loading branch information
wsfulton committed Feb 9, 2017
1 parent b3a61a3 commit dee6b07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Examples/test-suite/errors/cpp_raw_string_termination.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%module xxx

%feature("docstring") func2 R"ABC(Calculate :math:`D^\nu \rho(x)`.)AB";
void func2(double* foo, int bar, char** baz);
2 changes: 2 additions & 0 deletions Examples/test-suite/errors/cpp_raw_string_termination.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cpp_raw_string_termination.i:3: Error: Unterminated raw string, started with R"ABC( is not terminated by )ABC"
cpp_raw_string_termination.i:3: Error: Syntax error in input(1).
4 changes: 4 additions & 0 deletions Source/Swig/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,10 @@ static int look(Scanner *s) {
str_delimiter = 0;
return SWIG_TOKEN_STRING;
} else { /* Incorrect end delimiter occured */
if (c == 0) {
Swig_error(cparse_file, cparse_start_line, "Unterminated raw string, started with R\"%s( is not terminated by )%s\"\n", str_delimiter, str_delimiter);
return SWIG_TOKEN_ERROR;
}
retract( s, i );
Delete( end_delimiter );
}
Expand Down

0 comments on commit dee6b07

Please sign in to comment.