diff options
author | Max Kellermann <max.kellermann@gmail.com> | 2017-12-04 08:33:47 +0100 |
---|---|---|
committer | Max Kellermann <max.kellermann@gmail.com> | 2017-12-04 10:38:19 +0100 |
commit | 2465e523fea3598b17e0c96ab63885f6e8aab3a6 (patch) | |
tree | 27ec7210b11d2df6624ae6d23723d024af52b327 | |
parent | bcc7211c793413adcd551c1e5369aeb0b43be54e (diff) | |
download | pesconvert-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.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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; } |