Skip to content

Commit

Permalink
Using official fix for packJPG memory corruption
Browse files Browse the repository at this point in the history
- See issue #17
- See packJPG git:
packjpg/packJPG@2d62eda
  • Loading branch information
schnaader committed Feb 17, 2016
1 parent 6c07ede commit 97081a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions contrib/packjpg/bitops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ reading and writing of arrays

// special realloc with guaranteed free() of previous memory
static inline void* frealloc( void* ptr, size_t size ) {
void* n_ptr = realloc( ptr, size );
// changed by schnaader to fix a bug: if size == 0, realloc will free the memory and n_ptr == NULL, in this case don't call free
if (( n_ptr == NULL ) && (size != 0)) free( ptr );
void* n_ptr = realloc( ptr, (size) ? size : 1 );
if ( n_ptr == NULL ) free( ptr );
return n_ptr;
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/packjpg/packjpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ packJPG by Matthias Stirner, 01/2014

// special realloc with guaranteed free() of previous memory
static inline void* frealloc( void* ptr, size_t size ) {
void* n_ptr = realloc( ptr, size );
void* n_ptr = realloc( ptr, (size) ? size : 1 );
if ( n_ptr == NULL ) free( ptr );
return n_ptr;
}
Expand Down

0 comments on commit 97081a4

Please sign in to comment.