Skip to content

Commit

Permalink
Don't fail to write a GIF if the background color pushes the color to…
Browse files Browse the repository at this point in the history
…tal over the limit
  • Loading branch information
aaaaaa123456789 committed Jan 20, 2022
1 parent 2bdb87e commit c66050c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/gifwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ void generate_GIF_data_with_palette (struct context * context, unsigned char * h
int_fast32_t background = get_GIF_background_color(context);
if (background >= 0) {
for (p = 0; p < colors; p ++) if (palette[p] == background) break;
if (p >= colors) {
if (colors == 256) throw(context, PLUM_ERR_TOO_MANY_COLORS);
palette[colors ++] = background;
}
background = p;
if ((p == colors) && (colors < 256)) palette[colors ++] = background;
background = (p < colors) ? p : -1;
}
for (p = 0; colors > (2 << p); p ++);
colors = 2 << p;
Expand Down

0 comments on commit c66050c

Please sign in to comment.