lib: Throw an error when ramdisk is present but initrd.size is 0

It fails if you call extract() when ramdisk is present but initrd
size is 0. This CL adds if-statement to throw an error when initrd
size is 0.

Change-Id: I85aa33d2c2846b6b3a58df834dda18c47433257d
Signed-off-by: Asami Doi <d0iasm.pub@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/34535
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Martin Roth <martinroth@google.com>
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index a4d3705..1b6c986 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -51,6 +51,11 @@
 	const char *comp_name;
 	size_t true_size = 0;
 
+	if (node->size == 0) {
+		printk(BIOS_ERR, "ERROR: The %s size is 0\n", node->name);
+		return true;
+	}
+
 	switch (node->compression) {
 	case CBFS_COMPRESS_NONE:
 		comp_name = "Relocating uncompressed";