In the resolve function - ensure on memory allocation error -
authorEzra Peisach <epeisach@mit.edu>
Mon, 12 Feb 2007 00:19:47 +0000 (00:19 +0000)
committerEzra Peisach <epeisach@mit.edu>
Mon, 12 Feb 2007 00:19:47 +0000 (00:19 +0000)
deref of null pointer does not happen.

Also include kt-int.h for prototypes.

ticket: 5411

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19153 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/keytab/kt_memory.c

index 044cb1f3bee35835a81b08c72936107a974e0fe6..e103e7685bef7ec2f1b7d9577e4810dcc5ff16f6 100644 (file)
@@ -25,6 +25,7 @@
  */\r
 \r
 #include "k5-int.h"\r
+#include "kt-int.h"\r
 #include <stdio.h>\r
 \r
 #define HEIMDAL_COMPATIBLE\r
@@ -200,7 +201,7 @@ void krb5int_mkt_finalize(void) {
 krb5_error_code KRB5_CALLCONV \r
 krb5_mkt_resolve(krb5_context context, const char *name, krb5_keytab *id)\r
 {\r
-    krb5_mkt_data *data;\r
+    krb5_mkt_data *data = 0;\r
     krb5_mkt_list_node *list;\r
     krb5_error_code err = 0;\r
 \r
@@ -275,9 +276,11 @@ krb5_mkt_resolve(krb5_context context, const char *name, krb5_keytab *id)
     err = KTLOCK(*id);\r
     if (err) {\r
        k5_mutex_destroy(&data->lock);\r
-       krb5_xfree(data->name);\r
+       if (data && data->name) \r
+               krb5_xfree(data->name);\r
        krb5_xfree(data);\r
-       krb5_xfree(list->keytab);\r
+       if (list && list->keytab)\r
+               krb5_xfree(list->keytab);\r
        krb5_xfree(list);\r
     } else {\r
        KTREFCNT(*id)++;\r