From 5176f4e3560743db5573f07328506e9c021c6d0b Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 31 May 1999 05:34:49 +0000 Subject: [PATCH] Free strings returned by ldap_get_option(). --- libraries/libldap/apitest.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libraries/libldap/apitest.c b/libraries/libldap/apitest.c index 0cb60e47a2..0274f39280 100644 --- a/libraries/libldap/apitest.c +++ b/libraries/libldap/apitest.c @@ -64,7 +64,7 @@ main(int argc, char **argv) printf(" Protocol Max: unknown\n"); #endif #ifdef LDAP_VENDOR_NAME - printf(" Vendor Name: %s\n", (int) LDAP_VENDOR_NAME); + printf(" Vendor Name: %s\n", LDAP_VENDOR_NAME); #else printf(" Vendor Name: unknown\n"); #endif @@ -75,7 +75,7 @@ main(int argc, char **argv) #endif if(ldap_get_option(NULL, LDAP_OPT_API_INFO, &api) != LDAP_SUCCESS) { - fprintf(stderr, "%s: ldap_get_option(api) failed\n", argv[0]); + fprintf(stderr, "%s: ldap_get_option(API_INFO) failed\n", argv[0]); return EXIT_FAILURE; } @@ -126,11 +126,16 @@ main(int argc, char **argv) #else printf(" %s\n", api.ldapai_extensions[i]); + #endif + ldap_memfree(api.ldapai_extensions[i]); } + ldap_memfree(api.ldapai_extensions); } printf(" Vendor Name: %s\n", api.ldapai_vendor_name); + ldap_memfree(api.ldapai_vendor_name); + printf(" Vendor Version: %d\n", api.ldapai_vendor_version); printf("\nExecution time Default Options\n"); @@ -177,7 +182,12 @@ main(int argc, char **argv) fprintf(stderr, "%s: ldap_get_option(host name) failed\n", argv[0]); return EXIT_FAILURE; } - printf(" HOST NAME: %s\n", sval); + if( sval != NULL ) { + printf(" HOST NAME: %s\n", sval); + ldap_memfree(sval); + } else { + printf(" HOST NAME: \n", sval); + } return EXIT_SUCCESS; } -- 2.39.5