summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max.kellermann@gmail.com>2017-12-04 08:33:47 +0100
committerMax Kellermann <max.kellermann@gmail.com>2017-12-04 10:38:19 +0100
commit2465e523fea3598b17e0c96ab63885f6e8aab3a6 (patch)
tree27ec7210b11d2df6624ae6d23723d024af52b327
parentbcc7211c793413adcd551c1e5369aeb0b43be54e (diff)
downloadpesconvert-2465e523fea3598b17e0c96ab63885f6e8aab3a6.tar.gz
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>
-rw-r--r--pes.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pes.c b/pes.c
index 1e6b0b3..07b2e0d 100644
--- a/pes.c
+++ b/pes.c
@@ -161,10 +161,15 @@ static struct pes_block *new_block(struct pes *pes)
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;
}