summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/grub2/parser.y3
-rw-r--r--test/parser/Makefile.am1
-rw-r--r--test/parser/test-grub2-empty.c10
3 files changed, 14 insertions, 0 deletions
diff --git a/discover/grub2/parser.y b/discover/grub2/parser.y
index 23bf427..9d79d9b 100644
--- a/discover/grub2/parser.y
+++ b/discover/grub2/parser.y
@@ -329,6 +329,9 @@ void grub2_parser_parse(struct grub2_parser *parser, const char *filename,
YY_BUFFER_STATE bufstate;
int rc;
+ if (!len)
+ return;
+
parser->script->filename = filename;
bufstate = yy_scan_bytes(buf, len - 1, parser->scanner);
diff --git a/test/parser/Makefile.am b/test/parser/Makefile.am
index b36889d..283b284 100644
--- a/test/parser/Makefile.am
+++ b/test/parser/Makefile.am
@@ -29,6 +29,7 @@ TESTS = \
test-null \
test-grub2-single \
test-grub2-default \
+ test-grub2-empty \
test-grub2-default-index \
test-grub2-default-multiword \
test-grub2-multiple-resolve \
diff --git a/test/parser/test-grub2-empty.c b/test/parser/test-grub2-empty.c
new file mode 100644
index 0000000..c7ebbeb
--- /dev/null
+++ b/test/parser/test-grub2-empty.c
@@ -0,0 +1,10 @@
+
+#include "parser-test.h"
+
+void run_test(struct parser_test *test)
+{
+ __test_read_conf_data(test, test->ctx->device,
+ "/grub2/grub.cfg", "", 0);
+ test_run_parser(test, "grub2");
+ check_boot_option_count(test->ctx, 0);
+}
OpenPOWER on IntegriCloud