Fix write-past-buffer-end in ldapServiceLookup().
Fix write-past-buffer-end in ldapServiceLookup().

The code to assemble ldap_get_values_len's output into a single string
wrote the terminating null one byte past where it should.  Fix that,
and make some other cosmetic adjustments to make the code a trifle more
readable and more in line with usual Postgres coding style.

Also, free the "result" string when done with it, to avoid a permanent
memory leak.

Bug report and patch by Albe Laurenz, cosmetic adjustments by me.

yazun/postgres-xl,lisakowen/gpdb,oberstet/postgres-xl,greenplum-db/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,techdragon/Postgres-XL,pavanvd/postgres-xl,tpostgres-projects/tPostgres,lisakowen/gpdb,adam8157/gpdb,zeroae/postgres-xl,adam8157/gpdb,yazun/postgres-xl,arcivanov/postgres-xl,kmjungersen/PostgresXL,xinzweb/gpdb,Postgres-XL/Postgres-XL,techdragon/Postgres-XL,oberstet/postgres-xl,50wu/gpdb,jmcatamney/gpdb,adam8157/gpdb,50wu/gpdb,greenplum-db/gpdb,snaga/postgres-xl,zeroae/postgres-xl,snaga/postgres-xl,kmjungersen/PostgresXL,50wu/gpdb,xinzweb/gpdb,adam8157/gpdb,xinzweb/gpdb,arcivanov/postgres-xl,xinzweb/gpdb,xinzweb/gpdb,techdragon/Postgres-XL,jmcatamney/gpdb,50wu/gpdb,greenplum-db/gpdb,postmind-net/postgres-xl,jmcatamney/gpdb,lisakowen/gpdb,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,yazun/postgres-xl,adam8157/gpdb,arcivanov/postgres-xl,arcivanov/postgres-xl,ovr/postgres-xl,ashwinstar/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,tpostgres-projects/tPostgres,pavanvd/postgres-xl,adam8157/gpdb,lisakowen/gpdb,xinzweb/gpdb,zeroae/postgres-xl,yazun/postgres-xl,ashwinstar/gpdb,yazun/postgres-xl,kmjungersen/PostgresXL,postmind-net/postgres-xl,jmcatamney/gpdb,xinzweb/gpdb,ovr/postgres-xl,50wu/gpdb,lisakowen/gpdb,oberstet/postgres-xl,zeroae/postgres-xl,jmcatamney/gpdb,zeroae/postgres-xl,tpostgres-projects/tPostgres,ovr/postgres-xl,kmjungersen/PostgresXL,techdragon/Postgres-XL,adam8157/gpdb,50wu/gpdb,snaga/postgres-xl,ovr/postgres-xl,ashwinstar/gpdb,xinzweb/gpdb,50wu/gpdb,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,Postgres-XL/Postgres-XL,ashwinstar/gpdb,ovr/postgres-xl,kmjungersen/PostgresXL,postmind-net/postgres-xl,tpostgres-projects/tPostgres,Postgres-XL/Postgres-XL,greenplum-db/gpdb,snaga/postgres-xl,techdragon/Postgres-XL,postmind-net/postgres-xl,ashwinstar/gpdb,tpostgres-projects/tPostgres,pavanvd/postgres-xl,greenplum-db/gpdb,greenplum-db/gpdb,arcivanov/postgres-xl,postmind-net/postgres-xl,oberstet/postgres-xl,snaga/postgres-xl,lisakowen/gpdb,lisakowen/gpdb,adam8157/gpdb,50wu/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,arcivanov/postgres-xl,lisakowen/gpdb,oberstet/postgres-xl