third_party/cairo/src/cairo-lzw.c
static cairo_status_t
_lzw_buf_grow (lzw_buf_t *buf)
{
    int new_size = buf->data_size * 2;
    unsigned char *new_data;

    if (buf->status)
	return buf->status;

    new_data = NULL;
    /* check for integer overflow */
    if (new_size / 2 == buf->data_size)
	new_data = realloc (buf->data, new_size);

    if (unlikely (new_data == NULL)) {
	free (buf->data);
	buf->data_size = 0;
	buf->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
	return buf->status;
    }

    buf->data = new_data;
    buf->data_size = new_size;

    return CAIRO_STATUS_SUCCESS;
}
/* Increase the buffer size by doubling.
 *
 * Returns %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY
 */
Increase the buffer size by doubling.
Increase the buffer size by doubling .
static cairo_status_t
_lzw_buf_grow (lzw_buf_t *buf)
{
    int new_size = buf->data_size * 2;
    unsigned char *new_data;
    if (buf->status)
	return buf->status;
    new_data = NULL;
    if (new_size / 2 == buf->data_size)
	new_data = realloc (buf->data, new_size);
    if (unlikely (new_data == NULL)) {
	free (buf->data);
	buf->data_size = 0;
	buf->status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
	return buf->status;
    }
    buf->data = new_data;
    buf->data_size = new_size;
    return CAIRO_STATUS_SUCCESS;
}
static cairo_status_t _lzw_buf_grow ( lzw_buf_t * buf ) { int new_size = buf -> data_size * 2 ; unsigned char * new_data ; if ( buf -> status ) return buf -> status ; new_data = NULL ; if ( new_size / 2 == buf -> data_size ) new_data = realloc ( buf -> data , new_size ) ; if ( unlikely ( new_data == NULL ) ) { free ( buf -> data ) ; buf -> data_size = 0 ; buf -> status = _cairo_error ( CAIRO_STATUS_NO_MEMORY ) ; return buf -> status ; } buf -> data = new_data ; buf -> data_size = new_size ; return CAIRO_STATUS_SUCCESS ; }
Increase the buffer size by doubling.
Increase the buffer size by doubling .
/* check for integer overflow */