memory: switch loop condition around in blas_memory_free
authorJames Cowgill <james410@cowgill.org.uk>
Thu, 4 May 2017 13:29:48 +0000 (14:29 +0100)
committerJames Cowgill <james410@cowgill.org.uk>
Fri, 5 May 2017 15:01:58 +0000 (16:01 +0100)
commit5fecfe0f42ae389dc962981334aa1f2d28272e53
tree6954d7e336a8011a1dea21b91da1639be7b85a61
parentbba6676803e574d433661d6ff35af8095299d024
memory: switch loop condition around in blas_memory_free

Before this commit, the "position < NUM_BUFFERS" loop condition from
blas_memory_free will be completely optimized away by GCC. This is
because the condition can only be false after undefined behavior has
already been invoked (reading past the end of an array). As a
consequence of this bug, GCC also removes the subsequent if statement
and all the code after the error label because all of it is dead.

This commit switches the loop condition around so it works as intended.
driver/others/memory.c