aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bugs-fixed/README3
-rw-r--r--bugs-fixed/missing-precision.awk1
-rw-r--r--bugs-fixed/missing-precision.ok2
-rw-r--r--run.c3
4 files changed, 9 insertions, 0 deletions
diff --git a/bugs-fixed/README b/bugs-fixed/README
index 222ef68..629db08 100644
--- a/bugs-fixed/README
+++ b/bugs-fixed/README
@@ -23,3 +23,6 @@ and also if CONVFMT changed.
7. unary-plus: Unary plus on a string constant returned the string.
Instead, it should convert the value to numeric and give that value.
+
+8. missing-precision: When using the format string "%*s", the precision
+argument was used without checking if it was present first.
diff --git a/bugs-fixed/missing-precision.awk b/bugs-fixed/missing-precision.awk
new file mode 100644
index 0000000..4e7a74b
--- /dev/null
+++ b/bugs-fixed/missing-precision.awk
@@ -0,0 +1 @@
+BEGIN { printf("%*s"); }
diff --git a/bugs-fixed/missing-precision.ok b/bugs-fixed/missing-precision.ok
new file mode 100644
index 0000000..608b4fa
--- /dev/null
+++ b/bugs-fixed/missing-precision.ok
@@ -0,0 +1,2 @@
+./a.out: not enough args in printf(%*s)
+ source line number 1
diff --git a/run.c b/run.c
index 81b75da..95380ef 100644
--- a/run.c
+++ b/run.c
@@ -863,6 +863,9 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
FATAL("'$' not permitted in awk formats");
}
if (*s == '*') {
+ if (a == NULL) {
+ FATAL("not enough args in printf(%s)", os);
+ }
x = execute(a);
a = a->nnext;
sprintf(t-1, "%d", fmtwd=(int) getfval(x));