Fix a memory management bug
authorKen Raeburn <raeburn@mit.edu>
Mon, 17 Nov 2008 21:28:04 +0000 (21:28 +0000)
committerKen Raeburn <raeburn@mit.edu>
Mon, 17 Nov 2008 21:28:04 +0000 (21:28 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21133 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kdb/kdb_convert.c

index 3846cba276604fadc87bd0d28cb9a160ab7a3d30..48858835a4cfd8d71ba52d6bad0aa202688a40eb 100644 (file)
@@ -285,10 +285,12 @@ conv_princ_2db(krb5_context context, krb5_principal *dbprinc,
                free(princ->data[i].data);
                princ->data[i].data = NULL;
            }
-       } else
+       } else {
            princ->data = NULL;
+           princ->length = 0;
+       }
        princ->data = (krb5_data *)realloc(princ->data,
-                                          (princ->length * sizeof (krb5_data)));
+                                          (kdbe_princ->k_components.k_components_len * sizeof (krb5_data)));
        if (princ->data == NULL)
            /* XXX Memory leak: old storage not freed.  */
            goto error;