diff --git a/connector/c/tntsql/tnt_lex.c b/connector/c/tntsql/tnt_lex.c index 3e7723972b88..a0e99465eebf 100644 --- a/connector/c/tntsql/tnt_lex.c +++ b/connector/c/tntsql/tnt_lex.c @@ -231,6 +231,10 @@ tnt_lex(struct tnt_lex *l, struct tnt_tk **tk) } else if (ch == '#') { while (1) { + if (l->pos == l->buf.size) { + *tk = tnt_lex_tk(l, TNT_TK_EOF, l->line, l->col); + return TNT_TK_EOF; + } tnt_lex_step(l); if (tnt_lex_chr(l) == '\n') { if (((l->pos + 1) != l->buf.size)) diff --git a/test/connector_c/tt.c b/test/connector_c/tt.c index 71c170f6901c..d6ddf34792db 100644 --- a/test/connector_c/tt.c +++ b/test/connector_c/tt.c @@ -797,7 +797,7 @@ static void tt_tnt_net_reply(struct tt_test *test) { /* lex ws */ static void tt_tnt_lex_ws(struct tt_test *test) { - unsigned char sz[] = " # abcde fghjk ## hh\n # zzz\n"; + unsigned char sz[] = " # abcde fghjk ## hh\n # zzz\n#NOCR"; struct tnt_lex l; tnt_lex_init(&l, sz, sizeof(sz) - 1); struct tnt_tk *tk;