Skip to content

Commit 3c325ca

Browse files
committed
Improving opal_pointer_array bounds checking.
1 parent 06dbcc1 commit 3c325ca

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

opal/class/opal_pointer_array.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ int opal_pointer_array_set_item(opal_pointer_array_t *table, int index,
166166
{
167167
assert(table != NULL);
168168

169+
if (0 > index) {
170+
return OPAL_ERROR;
171+
}
172+
169173
/* expand table if required to set a specific index */
170174

171175
OPAL_THREAD_LOCK(&(table->lock));

opal/class/opal_pointer_array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static inline void *opal_pointer_array_get_item(opal_pointer_array_t *table,
124124
{
125125
void *p;
126126

127-
if( table->size <= element_index ) {
127+
if( 0 > element_index || table->size <= element_index ) {
128128
return NULL;
129129
}
130130
OPAL_THREAD_LOCK(&(table->lock));

0 commit comments

Comments
 (0)