pes: new_block() fails if undefined color is referenced

Fixes crash when the file's color table is too short.

Signed-off-by: Max Kellermann <max.kellermann@gmail.com>
diff --git a/pes.c b/pes.c
index 1e6b0b3..07b2e0d 100644
--- a/pes.c
+++ b/pes.c
@@ -161,10 +161,15 @@
 	struct pes_block *block = calloc(1, sizeof(*block));
 
 	if (block) {
+		block->color = my_colors[pes->nr_colors++];
+		if (!block->color) {
+			free(block);
+			return NULL;
+		}
+
 		struct pes_block **pp = pes->last ? &pes->last->next : &pes->blocks;
 		*pp = block;
 		pes->last = block;
-		block->color = my_colors[pes->nr_colors++];
 	}
 	return block;
 }