* strports.c (st_end_input): avoid dubious pointer arithmetic.
[bpt/guile.git] / libguile / strports.c
index d76a600..19e2ba1 100644 (file)
@@ -149,12 +149,11 @@ static void
 st_end_input (SCM port, int offset)
 {
   scm_port *pt = SCM_PTAB_ENTRY (port);
-  const unsigned char *pos = pt->read_pos - offset;
-
-  if (pos < pt->read_buf)
-    scm_misc_error ("st_end_input", "negative position", SCM_EOL);
   
-  pt->write_pos = (unsigned char *) pt->read_pos = pos;
+  if (pt->read_pos - pt->read_buf < offset)
+    scm_misc_error ("st_end_input", "negative position", SCM_EOL);
+
+  pt->write_pos = (unsigned char *) pt->read_pos = pt->read_pos - offset;
   pt->rw_active = SCM_PORT_NEITHER;
 }