From 3064af4ddef72b846912f5111b2215050dd8ee49 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Sat, 16 Oct 2021 08:27:52 +0200 Subject: [PATCH] fix(terraform): avoid oom parsing empty file (#12182) --- lib/manager/terraform/providers.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/manager/terraform/providers.ts b/lib/manager/terraform/providers.ts index a74b5ca53d..09e925df26 100644 --- a/lib/manager/terraform/providers.ts +++ b/lib/manager/terraform/providers.ts @@ -36,7 +36,8 @@ export function extractTerraformProvider( } const line = lines[lineNumber]; - if (line) { + // istanbul ignore next + if (is.string(line)) { // `{` will be counted wit +1 and `}` with -1. Therefore if we reach braceCounter == 0. We have found the end of the terraform block const openBrackets = (line.match(/\{/g) || []).length; const closedBrackets = (line.match(/\}/g) || []).length; @@ -54,6 +55,9 @@ export function extractTerraformProvider( } } } + } else { + // stop - something went wrong + braceCounter = 0; } lineNumber += 1; } while (braceCounter !== 0); -- GitLab