lib/libdsa/dsalib_util.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
New commits:
commit 9047b26a1633f3ca7b049add8e16a8e44d7ad579
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Thu Apr 28 08:28:32 2011 -0700
Bug 700532 - (cov#10832) Incorrect if condition in dsalib
The dsalib code has an incorrect if condition in ds_get_file_list().
It looks like the condition at line 114/115 should be checking if the
realloc failed so we can avoid filling in ret if we were unable to
allocate memory.
diff --git a/lib/libdsa/dsalib_util.c b/lib/libdsa/dsalib_util.c
index 23f2bac..15eb512 100644
--- a/lib/libdsa/dsalib_util.c
+++ b/lib/libdsa/dsalib_util.c
@@ -112,9 +112,10 @@ ds_get_file_list( char *dir )
if ( strcmp( direntp->d_name, "." ) &&
strcmp( direntp->d_name, ".." )) {
if (( ret = (char **) realloc( ret,
- sizeof( char * ) * ( nfiles + 2 ))) == NULL );
- ret[ nfiles ] = strdup( direntp->d_name );
- nfiles++;
+ sizeof( char * ) * ( nfiles + 2 ))) != NULL ) {
+ ret[ nfiles ] = strdup( direntp->d_name );
+ nfiles++;
+ }
}
}
(void) closedir( dirp );
Show replies by date