From c295b834a2554b3f7eb792f1bc6d445e206fa55d Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Tue, 2 Apr 2013 11:13:39 +0200 Subject: [PATCH] Minor checks to prevent NULL-pointer exceptions --- include/polarssl/md.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/polarssl/md.h b/include/polarssl/md.h index b81ebf1be..d9ab5e74b 100644 --- a/include/polarssl/md.h +++ b/include/polarssl/md.h @@ -200,6 +200,9 @@ int md_free_ctx( md_context_t *ctx ); */ static inline unsigned char md_get_size( const md_info_t *md_info ) { + if( md_info == NULL ) + return( 0 ); + return md_info->size; } @@ -212,6 +215,9 @@ static inline unsigned char md_get_size( const md_info_t *md_info ) */ static inline md_type_t md_get_type( const md_info_t *md_info ) { + if( md_info == NULL ) + return( POLARSSL_MD_NONE ); + return md_info->type; } @@ -224,6 +230,9 @@ static inline md_type_t md_get_type( const md_info_t *md_info ) */ static inline const char *md_get_name( const md_info_t *md_info ) { + if( md_info == NULL ) + return( NULL ); + return md_info->name; }