diff options
Diffstat (limited to 'cpukit/libcsupport/src/calloc.c')
-rw-r--r-- | cpukit/libcsupport/src/calloc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cpukit/libcsupport/src/calloc.c b/cpukit/libcsupport/src/calloc.c index 693aa21453..d5cefb382a 100644 --- a/cpukit/libcsupport/src/calloc.c +++ b/cpukit/libcsupport/src/calloc.c @@ -35,14 +35,15 @@ void *calloc( size_t length; if ( nelem == 0 ) { - length = 0; - } else if ( elsize > SIZE_MAX / nelem ) { + return NULL; + } + + if ( elsize > SIZE_MAX / nelem ) { errno = ENOMEM; return NULL; - } else { - length = nelem * elsize; } + length = nelem * elsize; cptr = malloc( length ); RTEMS_OBFUSCATE_VARIABLE( cptr ); if ( RTEMS_PREDICT_FALSE( cptr == NULL ) ) { |