summaryrefslogtreecommitdiff
path: root/src/port/snprintf.c
diff options
context:
space:
mode:
authorTom Lane2018-02-14 20:06:01 +0000
committerTom Lane2018-02-14 20:06:01 +0000
commit0c62356cc8777961221a643fa77f62e1c7361085 (patch)
tree264a983eb1d9b878083f353615ab2a9b9118953c /src/port/snprintf.c
parente748e902def40ee52d1ef0b770fd24aa0835e304 (diff)
Add an assertion that we don't pass NULL to snprintf("%s").
Per commit e748e902d, we appear to have little or no coverage in the buildfarm of machines that will dump core when asked to printf a null string pointer. Let's try to improve that situation by adding an assertion that will make src/port/snprintf.c behave that way. Since it's just an assertion, it won't break anything in production builds, but it will help developers find this type of oversight. Note that while our buildfarm coverage of machines that use that snprintf implementation is pretty thin on the Unix side (apparently amounting only to gaur/pademelon), all of the MSVC critters use it. Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/port/snprintf.c')
-rw-r--r--src/port/snprintf.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 43c17e702e2..83584259802 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -745,6 +745,8 @@ nextch2:
strvalue = argvalues[fmtpos].cptr;
else
strvalue = va_arg(args, char *);
+ /* Whine if someone tries to print a NULL string */
+ Assert(strvalue != NULL);
fmtstr(strvalue, leftjust, fieldwidth, precision, pointflag,
target);
break;