- Check for failed malloc() in ssl_set_hostname() and x509_get_entries() (Closes ticket #47, found by Hugo Leisink)


diff --git a/library/x509parse.c b/library/x509parse.c
index f561754..ec4fffc 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -968,6 +968,10 @@
         if ( *p < end )
         {
             cur_entry->next = malloc( sizeof( x509_crl_entry ) );
+
+            if( cur_entry->next == NULL )
+                return( POLARSSL_ERR_X509_MALLOC_FAILED );
+
             cur_entry = cur_entry->next;
             memset( cur_entry, 0, sizeof( x509_crl_entry ) );
         }