diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c new file mode 100644 index 1b409d1..e4b152a *** a/src/interfaces/libpq/fe-connect.c --- b/src/interfaces/libpq/fe-connect.c *************** ldapServiceLookup(const char *purl, PQco *** 3612,3620 **** strncpy(p, values[i]->bv_val, values[i]->bv_len); p += values[i]->bv_len; *(p++) = '\n'; - if (values[i + 1] == NULL) - *(p + 1) = '\0'; } ldap_value_free_len(values); ldap_unbind(ld); --- 3612,3619 ---- strncpy(p, values[i]->bv_val, values[i]->bv_len); p += values[i]->bv_len; *(p++) = '\n'; } + *p = '\0'; ldap_value_free_len(values); ldap_unbind(ld); *************** ldapServiceLookup(const char *purl, PQco *** 3643,3648 **** --- 3642,3648 ---- printfPQExpBuffer(errorMessage, libpq_gettext( "missing \"=\" after \"%s\" in connection info string\n"), optname); + free(result); return 3; } else if (*p == '=') *************** ldapServiceLookup(const char *purl, PQco *** 3661,3666 **** --- 3661,3667 ---- printfPQExpBuffer(errorMessage, libpq_gettext( "missing \"=\" after \"%s\" in connection info string\n"), optname); + free(result); return 3; } break; *************** ldapServiceLookup(const char *purl, PQco *** 3731,3736 **** --- 3732,3738 ---- } oldstate = state; } + free(result); if (state == 5 || state == 6) {