Disallow null category in crosstab_hash
authorJoe Conway <mail@joeconway.com>
Mon, 23 Dec 2019 18:34:05 +0000 (13:34 -0500)
committerJoe Conway <mail@joeconway.com>
Mon, 23 Dec 2019 18:34:05 +0000 (13:34 -0500)
commit70fc6c4ef3c3790284796db3935d6f2d040b60bd
tree2addabe7446dd47fa36e112b535df52eae2e6001
parent6609c3ad984bde125ff6ec4e3e056a5b23f68210
Disallow null category in crosstab_hash

While building a hash map of categories in load_categories_hash,
resulting category names have not thus far been checked to ensure
they are not null. Prior to pg12 null category names worked to the
extent that they did not crash on some platforms. This is because
those system libraries have an snprintf which can deal with being
passed a null pointer argument for a string. But even in those cases
null categories did nothing useful. And on some platforms it crashed.
As of pg12, our own version of snprintf gets called, and it does
not deal with null pointer arguments at all, and crashes consistently.

Fix that by disallowing null categories. They never worked usefully,
and no one has ever asked for them to work previously. Back-patch to
all supported branches.

Reported-By: Ireneusz Pluta
Discussion: https://postgr.es/m/16176-7489719b05e4303c@postgresql.org
contrib/tablefunc/tablefunc.c