Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions gifdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ gd_open_gif(const char *fname)
/* Aspect Ratio */
read(fd, &aspect, 1);
/* Create gd_GIF Structure. */
gif = calloc(1, sizeof(*gif));
gif = (gd_GIF *)calloc(1, sizeof(*gif));
if (!gif) goto fail;
gif->fd = fd;
gif->width = width;
Expand All @@ -97,7 +97,7 @@ gd_open_gif(const char *fname)
read(fd, gif->gct.colors, 3 * gif->gct.size);
gif->palette = &gif->gct;
gif->bgindex = bgidx;
gif->frame = calloc(4, width * height);
gif->frame = (uint8_t *)calloc(4, width * height);
if (!gif->frame) {
free(gif);
goto fail;
Expand Down Expand Up @@ -240,9 +240,9 @@ read_ext(gd_GIF *gif)
static Table *
new_table(int key_size)
{
int key;
u_int8_t key;
int init_bulk = MAX(1 << (key_size + 1), 0x100);
Table *table = malloc(sizeof(*table) + sizeof(Entry) * init_bulk);
Table *table = (Table *)malloc(sizeof(*table) + sizeof(Entry) * init_bulk);
if (table) {
table->bulk = init_bulk;
table->nentries = (1 << key_size) + 2;
Expand All @@ -263,7 +263,7 @@ add_entry(Table **tablep, uint16_t length, uint16_t prefix, uint8_t suffix)
Table *table = *tablep;
if (table->nentries == table->bulk) {
table->bulk *= 2;
table = realloc(table, sizeof(*table) + sizeof(Entry) * table->bulk);
table = (Table *)realloc(table, sizeof(*table) + sizeof(Entry) * table->bulk);
if (!table) return -1;
table->entries = (Entry *) &table[1];
*tablep = table;
Expand Down Expand Up @@ -333,8 +333,8 @@ static int
read_image_data(gd_GIF *gif, int interlace)
{
uint8_t sub_len, shift, byte;
int init_key_size, key_size, table_is_full;
int frm_off, frm_size, str_len, i, p, x, y;
int init_key_size, key_size, table_is_full = 0;
int frm_off, frm_size, str_len = 0, i, p, x, y;
uint16_t key, clear, stop;
int ret;
Table *table;
Expand All @@ -345,7 +345,7 @@ read_image_data(gd_GIF *gif, int interlace)
key_size = (int) byte;
if (key_size < 2 || key_size > 8)
return -1;

start = lseek(gif->fd, 0, SEEK_CUR);
discard_sub_blocks(gif);
end = lseek(gif->fd, 0, SEEK_CUR);
Expand Down Expand Up @@ -416,16 +416,16 @@ read_image(gd_GIF *gif)
/* Image Descriptor. */
gif->fx = read_num(gif->fd);
gif->fy = read_num(gif->fd);

if (gif->fx >= gif->width || gif->fy >= gif->height)
return -1;

gif->fw = read_num(gif->fd);
gif->fh = read_num(gif->fd);

gif->fw = MIN(gif->fw, gif->width - gif->fx);
gif->fh = MIN(gif->fh, gif->height - gif->fy);

read(gif->fd, &fisrz, 1);
interlace = fisrz & 0x40;
/* Ignore Sort Flag. */
Expand Down Expand Up @@ -525,6 +525,6 @@ void
gd_close_gif(gd_GIF *gif)
{
close(gif->fd);
free(gif->frame);
free(gif->frame);
free(gif);
}