about summary refs log tree commit diff
path: root/hurd/report-wait.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-05-01 01:01:48 +0000
committerMiles Bader <miles@gnu.org>1996-05-01 01:01:48 +0000
commitd3dc731b4741072b890428b1e125228fcb8bf4a2 (patch)
tree2635ca30b17805379671788e3f0cf0b031227937 /hurd/report-wait.c
parent06f82985cb4ea5b421321c07ee2215644656de0a (diff)
downloadglibc-d3dc731b4741072b890428b1e125228fcb8bf4a2.tar.gz
glibc-d3dc731b4741072b890428b1e125228fcb8bf4a2.tar.xz
glibc-d3dc731b4741072b890428b1e125228fcb8bf4a2.zip
(describe_number): Correctly allocate space in DESCRIPTION for the digits in I.
Diffstat (limited to 'hurd/report-wait.c')
-rw-r--r--hurd/report-wait.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/hurd/report-wait.c b/hurd/report-wait.c
index 521c5220b9..35cf7c1a61 100644
--- a/hurd/report-wait.c
+++ b/hurd/report-wait.c
@@ -29,15 +29,20 @@ Cambridge, MA 02139, USA.  */
 static void
 describe_number (string_t description, const char *flavor, int i)
 {
+  int j;
   char *p = __stpcpy (description, flavor);
-  p += i / 10 + 1;
-  *p = '\0';
+
+  /* Allocate space for the number at the end of DESCRIPTION.  */
+  for (j = i; j >= 10; j /= 10)
+    p++;
+  p[1] = '\0';
+
   do
     {
-      *--p = '0' + i % 10;
+      *p-- = '0' + i % 10;
       i /= 10;
     } while (i != 0);
-  assert (p[-1] == '#');
+  assert (*p == '#');
 }
 
 static void