|
1 | | -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. |
2 | | - Copyright (c) 2009, 2018, MariaDB Corporation |
| 1 | +/* Copyright (c) 2000, 2019, Oracle and/or its affiliates. |
| 2 | + Copyright (c) 2009, 2020, MariaDB Corporation |
3 | 3 |
|
4 | 4 | This program is free software; you can redistribute it and/or modify |
5 | 5 | it under the terms of the GNU General Public License as published by |
@@ -940,17 +940,27 @@ static inline uint int_token(const char *str,uint length) |
940 | 940 | */ |
941 | 941 | bool consume_comment(Lex_input_stream *lip, int remaining_recursions_permitted) |
942 | 942 | { |
| 943 | + // only one level of nested comments are allowed |
| 944 | + DBUG_ASSERT(remaining_recursions_permitted == 0 || |
| 945 | + remaining_recursions_permitted == 1); |
943 | 946 | reg1 uchar c; |
944 | 947 | while (! lip->eof()) |
945 | 948 | { |
946 | 949 | c= lip->yyGet(); |
947 | 950 |
|
948 | | - if (remaining_recursions_permitted > 0) |
| 951 | + if (remaining_recursions_permitted == 1) |
949 | 952 | { |
950 | 953 | if ((c == '/') && (lip->yyPeek() == '*')) |
951 | 954 | { |
| 955 | + lip->yyUnput('('); // Replace nested "/*..." with "(*..." |
| 956 | + lip->yySkip(); // and skip "(" |
| 957 | + |
952 | 958 | lip->yySkip(); /* Eat asterisk */ |
953 | | - consume_comment(lip, remaining_recursions_permitted-1); |
| 959 | + if (consume_comment(lip, 0)) |
| 960 | + return true; |
| 961 | + |
| 962 | + lip->yyUnput(')'); // Replace "...*/" with "...*)" |
| 963 | + lip->yySkip(); // and skip ")" |
954 | 964 | continue; |
955 | 965 | } |
956 | 966 | } |
|
0 commit comments