summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/objectextendinformation.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-06-21 16:27:37 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-06-21 16:27:37 +0000
commitad376300acbe6ef6505127e61ea3653e98d89558 (patch)
treebe1c5cca0468663ef4532d7870341b2980a34486 /cpukit/score/src/objectextendinformation.c
parent2010-06-21 Joel Sherrill <joel.sherrilL@OARcorp.com> (diff)
downloadrtems-ad376300acbe6ef6505127e61ea3653e98d89558.tar.bz2
2010-06-21 Joel Sherrill <joel.sherrilL@OARcorp.com>
PR 1554/cpukit Coverity Id 17 * libi2c/libi2c.c, score/src/objectextendinformation.c: Fix memory leak on error.
Diffstat (limited to 'cpukit/score/src/objectextendinformation.c')
-rw-r--r--cpukit/score/src/objectextendinformation.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c
index c56a8311eb..ef10e63947 100644
--- a/cpukit/score/src/objectextendinformation.c
+++ b/cpukit/score/src/objectextendinformation.c
@@ -56,11 +56,13 @@ void _Objects_Extend_information(
uint32_t maximum;
size_t block_size;
void *new_object_block;
+ bool do_extend;
/*
- * Search for a free block of indexes. The block variable ends up set
- * to block_count + 1 if the table needs to be extended.
+ * Search for a free block of indexes. If we do NOT need to allocate or
+ * extend the block table, then we will change do_extend.
*/
+ do_extend = true;
minimum_index = _Objects_Get_index( information->minimum_id );
index_base = minimum_index;
block = 0;
@@ -72,9 +74,10 @@ void _Objects_Extend_information(
block_count = information->maximum / information->allocation_size;
for ( ; block < block_count; block++ ) {
- if ( information->object_blocks[ block ] == NULL )
+ if ( information->object_blocks[ block ] == NULL ) {
+ do_extend = false;
break;
- else
+ } else
index_base += information->allocation_size;
}
}
@@ -104,9 +107,9 @@ void _Objects_Extend_information(
}
/*
- * If the index_base is the maximum we need to grow the tables.
+ * Do we need to grow the tables?
*/
- if (index_base >= information->maximum ) {
+ if ( do_extend ) {
ISR_Level level;
void **object_blocks;
uint32_t *inactive_per_block;