Avoid integer overflow in hstore_to_json().
Avoid integer overflow in hstore_to_json().

The length of the output buffer was calculated based on the size of the
argument hstore. On a sizeof(int) == 4 platform and a huge argument, it
could overflow, causing a too small buffer to be allocated.

Refactor the function to use a StringInfo instead of pre-allocating the
buffer. Makes it shorter and more readable, too.

jmcatamney/gpdb,adam8157/gpdb,adam8157/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,oberstet/postgres-xl,50wu/gpdb,Postgres-XL/Postgres-XL,Postgres-XL/Postgres-XL,adam8157/gpdb,greenplum-db/gpdb,yazun/postgres-xl,lisakowen/gpdb,Postgres-XL/Postgres-XL,ovr/postgres-xl,ashwinstar/gpdb,pavanvd/postgres-xl,ashwinstar/gpdb,oberstet/postgres-xl,greenplum-db/gpdb,zeroae/postgres-xl,xinzweb/gpdb,oberstet/postgres-xl,lisakowen/gpdb,Postgres-XL/Postgres-XL,jmcatamney/gpdb,ovr/postgres-xl,techdragon/Postgres-XL,jmcatamney/gpdb,zeroae/postgres-xl,xinzweb/gpdb,ashwinstar/gpdb,yazun/postgres-xl,xinzweb/gpdb,Postgres-XL/Postgres-XL,greenplum-db/gpdb,xinzweb/gpdb,techdragon/Postgres-XL,50wu/gpdb,50wu/gpdb,50wu/gpdb,oberstet/postgres-xl,oberstet/postgres-xl,adam8157/gpdb,adam8157/gpdb,zeroae/postgres-xl,lisakowen/gpdb,ovr/postgres-xl,yazun/postgres-xl,pavanvd/postgres-xl,lisakowen/gpdb,ashwinstar/gpdb,techdragon/Postgres-XL,xinzweb/gpdb,greenplum-db/gpdb,adam8157/gpdb,50wu/gpdb,pavanvd/postgres-xl,50wu/gpdb,ashwinstar/gpdb,ovr/postgres-xl,lisakowen/gpdb,pavanvd/postgres-xl,zeroae/postgres-xl,jmcatamney/gpdb,jmcatamney/gpdb,xinzweb/gpdb,ovr/postgres-xl,adam8157/gpdb,zeroae/postgres-xl,xinzweb/gpdb,lisakowen/gpdb,pavanvd/postgres-xl,lisakowen/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,yazun/postgres-xl,lisakowen/gpdb,yazun/postgres-xl,techdragon/Postgres-XL,jmcatamney/gpdb,xinzweb/gpdb,50wu/gpdb,jmcatamney/gpdb,techdragon/Postgres-XL,ashwinstar/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,50wu/gpdb