Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

resolved the realloc problem

  • Loading branch information...
commit 93212217faa940bb01a0af4907d50e94ef3a2838 1 parent 07e1b92
@pkrumins pkrumins authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/gif_encoder.cpp
View
6 src/gif_encoder.cpp
@@ -127,14 +127,14 @@ int
gif_writer(GifFileType *gif_file, const GifByteType *data, int size)
{
GifImage *gif = (GifImage *)gif_file->UserData;
- if (gif->mem_size < gif->size + size) {
- GifByteType *new_ptr = (GifByteType *)realloc(gif->gif, gif->size + size + 1000*1024);
+ if (gif->size + size > gif->mem_size) {
+ GifByteType *new_ptr = (GifByteType *)realloc(gif->gif, gif->size + size + 10*1024);
if (!new_ptr) {
free(gif->gif);
throw "realloc in gif_writer failed";
}
gif->gif = new_ptr;
- gif->mem_size += size + 1000*1024;
+ gif->mem_size = gif->size + size + 10*1024;
}
memcpy(gif->gif + gif->size, data, size);
gif->size += size;
Please sign in to comment.
Something went wrong with that request. Please try again.