[webkit-changes] [WebKit/WebKit] 65d409: [WGSL] Unterminated block comments crash the lexer

Tadeu Zagallo noreply at github.com
Tue Aug 1 08:53:08 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 65d409260e7651b06c4a66b438b80b75dd00cd33
      https://github.com/WebKit/WebKit/commit/65d409260e7651b06c4a66b438b80b75dd00cd33
  Author: Tadeu Zagallo <tzagallo at apple.com>
  Date:   2023-08-01 (Tue, 01 Aug 2023)

  Changed paths:
    M Source/WebGPU/WGSL/Lexer.cpp
    M Source/WebGPU/WGSL/Lexer.h
    M Source/WebGPU/WGSL/Parser.cpp
    A Source/WebGPU/WGSL/tests/invalid/unterminated-comment.wgsl

  Log Message:
  -----------
  [WGSL] Unterminated block comments crash the lexer
https://bugs.webkit.org/show_bug.cgi?id=259661
rdar://113161516

Reviewed by Dan Glastonbury.

In Lexer::skipBlockComments, we need to check if we are at the end of the file
before we shift. I also had to tweak the parser since it would ignore the first
token if it's the only token. This happens because we call `lex()` when constructing
the parser and then check if the lexer is at the end of the file, instead of the
checking the token produced by `lex()`.

* Source/WebGPU/WGSL/Lexer.cpp:
(WGSL::Lexer<T>::lex):
(WGSL::Lexer<T>::shift):
(WGSL::Lexer<T>::skipBlockComments):
(WGSL::Lexer<T>::skipWhitespaceAndComments):
* Source/WebGPU/WGSL/Lexer.h:
* Source/WebGPU/WGSL/Parser.cpp:
(WGSL::Parser<Lexer>::parseShader):
* Source/WebGPU/WGSL/tests/invalid/unterminated-comment.wgsl: Added.

Canonical link: https://commits.webkit.org/266476@main




More information about the webkit-changes mailing list