Merge pull request #2874 from Flamefire/memory_fixes
Avoid out of bounds access on invalid memory free
This commit is contained in:
commit
f032d8966e
|
@ -1107,7 +1107,7 @@ static volatile int memory_initialized = 0;
|
||||||
/* 1 : Level 2 functions */
|
/* 1 : Level 2 functions */
|
||||||
/* 2 : Thread */
|
/* 2 : Thread */
|
||||||
|
|
||||||
static void blas_memory_cleanup(void* ptr){
|
static void blas_memory_cleanup(void* ptr){
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
struct alloc_t ** table = (struct alloc_t **)ptr;
|
struct alloc_t ** table = (struct alloc_t **)ptr;
|
||||||
int pos;
|
int pos;
|
||||||
|
@ -2882,9 +2882,10 @@ void blas_memory_free(void *free_area){
|
||||||
while ((position < NUM_BUFFERS) && (memory[position].addr != free_area))
|
while ((position < NUM_BUFFERS) && (memory[position].addr != free_area))
|
||||||
position++;
|
position++;
|
||||||
|
|
||||||
if (memory[position].addr != free_area) goto error;
|
if (position >= NUM_BUFFERS) goto error;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
if (memory[position].addr != free_area) goto error;
|
||||||
printf(" Position : %d\n", position);
|
printf(" Position : %d\n", position);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue