From 9e17e8520f182ac81fb4f1092281a6969bf93083 Mon Sep 17 00:00:00 2001 From: "Hong, Yang A" Date: Thu, 4 Mar 2021 16:13:46 +0000 Subject: [PATCH] literal API: add empty string check. fixes github issue #302, #304 --- src/compiler/compiler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/compiler.cpp b/src/compiler/compiler.cpp index 5751bd64..15a130dd 100644 --- a/src/compiler/compiler.cpp +++ b/src/compiler/compiler.cpp @@ -416,6 +416,10 @@ void addLitExpression(NG &ng, unsigned index, const char *expression, "HS_FLAG_SOM_LEFTMOST are supported in literal API."); } + if (!strcmp(expression, "")) { + throw CompileError("Pure literal API doesn't support empty string."); + } + // This expression must be a pure literal, we can build ue2_literal // directly based on expression text. ParsedLitExpression ple(index, expression, expLength, flags, id);