Merge pull request #709 from avilcheslopez/master
Improving opal_pointer_array bounds checking.
Этот коммит содержится в:
Коммит
df800286e4
@ -166,6 +166,10 @@ int opal_pointer_array_set_item(opal_pointer_array_t *table, int index,
|
|||||||
{
|
{
|
||||||
assert(table != NULL);
|
assert(table != NULL);
|
||||||
|
|
||||||
|
if (OPAL_UNLIKELY(0 > index)) {
|
||||||
|
return OPAL_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* expand table if required to set a specific index */
|
/* expand table if required to set a specific index */
|
||||||
|
|
||||||
OPAL_THREAD_LOCK(&(table->lock));
|
OPAL_THREAD_LOCK(&(table->lock));
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "opal/threads/mutex.h"
|
#include "opal/threads/mutex.h"
|
||||||
#include "opal/class/opal_object.h"
|
#include "opal/class/opal_object.h"
|
||||||
|
#include "opal/prefetch.h"
|
||||||
|
|
||||||
BEGIN_C_DECLS
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ static inline void *opal_pointer_array_get_item(opal_pointer_array_t *table,
|
|||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if( table->size <= element_index ) {
|
if( OPAL_UNLIKELY(0 > element_index || table->size <= element_index) ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
OPAL_THREAD_LOCK(&(table->lock));
|
OPAL_THREAD_LOCK(&(table->lock));
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user