From 7d6635b4724e59086695239e771cdbc4543ec688 Mon Sep 17 00:00:00 2001 From: David Anson Date: Sun, 6 Jan 2019 22:07:10 -0800 Subject: [PATCH] Fix possible null-dereference if RegExp does not match in MD038. --- lib/md038.js | 2 +- test/backslashes-and-backticks.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/backslashes-and-backticks.md diff --git a/lib/md038.js b/lib/md038.js index 25314197..3019a600 100644 --- a/lib/md038.js +++ b/lib/md038.js @@ -19,7 +19,7 @@ module.exports = { inlineCodeSpansRe.lastIndex = 0; } const match = inlineCodeSpansRe.exec(parent.content); - const content = match[3]; + const content = (match || [])[3]; const leftError = /^\s([^`]|$)/.test(content); const rightError = /[^`]\s$/.test(content); if (leftError || rightError) { diff --git a/test/backslashes-and-backticks.md b/test/backslashes-and-backticks.md new file mode 100644 index 00000000..6a213d1a --- /dev/null +++ b/test/backslashes-and-backticks.md @@ -0,0 +1,4 @@ +# Heading + +\\`\\ +\\`\\