2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>

Coverity Id 27
	* libmisc/fsmount/fsmount.c: Ensure calloc() returns memory and then we
	do not have to check null when freeing it. Coverity noted it was used
	before being checked for NULL.
This commit is contained in:
Joel Sherrill
2010-01-20 16:24:11 +00:00
parent 8c161f958f
commit 59f7e9177a
2 changed files with 17 additions and 6 deletions
+7
View File
@@ -1,3 +1,10 @@
2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 27
* libmisc/fsmount/fsmount.c: Ensure calloc() returns memory and then we
do not have to check null when freeing it. Coverity noted it was used
before being checked for NULL.
2010-01-20 Joel Sherrill <joel.sherrill@oarcorp.com>
Coverity Id 3
+10 -6
View File
@@ -70,14 +70,20 @@ int rtems_fsmount_create_mount_point
* allocate temp memory to rebuild path name
*/
tok_buffer = calloc(strlen(mount_point)+1,sizeof(char));
if ( !tok_buffer )
return -1;
token = tok_buffer;
total_len = 0;
do {
/*
* scan through given string, one segment at a time
*/
token_type = IMFS_get_token(mount_point+total_len,strlen(mount_point+total_len),
token,&token_len);
token_type = IMFS_get_token(
mount_point+total_len,
strlen(mount_point+total_len),
token,
&token_len
);
total_len += token_len;
strncpy(tok_buffer,mount_point,total_len);
tok_buffer[total_len] = '\0';
@@ -100,11 +106,9 @@ int rtems_fsmount_create_mount_point
(token_type != IMFS_INVALID_TOKEN));
/*
* return token buffer to heap
* return token buffer to heap. Verified to be non-NULL when calloc'ed.
*/
if (tok_buffer != NULL) {
free(tok_buffer);
}
free(tok_buffer);
return rc;
}