Fix a realloc problem with indirect vertex arrays. The actual head pointer

wasn't tracked and used for the realloc, so it tended to explode.
This commit is contained in:
Ian Romanick 2005-08-19 18:53:26 +00:00
parent b7c727e500
commit 2ae5645115
2 changed files with 6 additions and 3 deletions

View File

@ -211,12 +211,14 @@ struct array_state_vector {
* There are some bytes of extra data before \c array_info_cache that is * There are some bytes of extra data before \c array_info_cache that is
* used to hold the header for RenderLarge commands. This is * used to hold the header for RenderLarge commands. This is
* \b not included in \c array_info_cache_size or * \b not included in \c array_info_cache_size or
* \c array_info_cache_buffer_size. * \c array_info_cache_buffer_size. \c array_info_cache_base stores a
* pointer to the true start of the buffer (i.e., what malloc returned).
*/ */
/*@{*/ /*@{*/
size_t array_info_cache_size; size_t array_info_cache_size;
size_t array_info_cache_buffer_size; size_t array_info_cache_buffer_size;
void * array_info_cache; void * array_info_cache;
void * array_info_cache_base;
/*@}*/ /*@}*/

View File

@ -382,13 +382,14 @@ allocate_array_info_cache( struct array_state_vector * arrays,
{ {
#define MAX_HEADER_SIZE 20 #define MAX_HEADER_SIZE 20
if ( arrays->array_info_cache_buffer_size < required_size ) { if ( arrays->array_info_cache_buffer_size < required_size ) {
GLubyte * temp = realloc( arrays->array_info_cache, required_size GLubyte * temp = realloc( arrays->array_info_cache_base,
+ MAX_HEADER_SIZE ); required_size + MAX_HEADER_SIZE );
if ( temp == NULL ) { if ( temp == NULL ) {
return GL_FALSE; return GL_FALSE;
} }
arrays->array_info_cache_base = temp;
arrays->array_info_cache = temp + MAX_HEADER_SIZE; arrays->array_info_cache = temp + MAX_HEADER_SIZE;
arrays->array_info_cache_buffer_size = required_size; arrays->array_info_cache_buffer_size = required_size;
} }