summaryrefslogtreecommitdiff
path: root/util/romcc/tests
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-05-17 12:51:47 -0600
committerPatrick Georgi <pgeorgi@google.com>2019-05-21 09:28:36 +0000
commitae8301fddbb5c8456b738bbeab94b98ae3eb06b6 (patch)
treef48cc998cd39784ace4c109b37677dc887e0bec4 /util/romcc/tests
parentb79d2dee2b2f294aac97dad849909d7bfb892c76 (diff)
downloadcoreboot-ae8301fddbb5c8456b738bbeab94b98ae3eb06b6.tar.xz
util/romcc: Fix parsing of empty string literal
The corner case of an empty string literal was causing romcc to segfault. This checks if the literal is empty, and if so allocates a size one buffer for the terminating null character. A test case for this is added to ensure it doesn't happen again. Found-by: Coverity CID 1129099 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Change-Id: I067160a3b9998184f44e4878ef6269f372fe68bb Reviewed-on: https://review.coreboot.org/c/coreboot/+/32852 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/romcc/tests')
-rw-r--r--util/romcc/tests/simple_test87.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/util/romcc/tests/simple_test87.c b/util/romcc/tests/simple_test87.c
new file mode 100644
index 0000000000..6a1148c46a
--- /dev/null
+++ b/util/romcc/tests/simple_test87.c
@@ -0,0 +1,4 @@
+static void main(void)
+{
+ char *x = "";
+}