Fix stupid bug in `copy_bits': code to generate mask was doing
authorChris Hanson <org/chris-hanson/cph>
Mon, 6 Mar 1995 21:45:34 +0000 (21:45 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 6 Mar 1995 21:45:34 +0000 (21:45 +0000)
    ((1 << 32) - 1)

and expecting something reasonable to happen on a 32-bit machine.

v7/src/microcode/bitstr.c

index 4e3a0c50e1851e1c068234d7e7b07e8c880283f6..251ac07cf26a43670d9e6a16b82843f650651a82 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: bitstr.c,v 9.54 1995/01/25 20:54:55 cph Exp $
+$Id: bitstr.c,v 9.55 1995/03/06 21:45:34 cph Exp $
 
 Copyright (c) 1987-95 Massachusetts Institute of Technology
 
@@ -508,10 +508,13 @@ DEFUN (copy_bits,
          {
            long mask = (ANY_MASK (head, offset1));
            dest_buffer
-             = (((BIT_STRING_WORD (destination))
-                 &~ (LOW_MASK (head + offset1)))
-                | (((* (DEC_BIT_STRING_PTR (source))) & (LOW_MASK (head)))
-                   << offset1));
+             = (((head + offset1) < OBJECT_LENGTH)
+                ? ((BIT_STRING_WORD (destination))
+                   &~ (LOW_MASK (head + offset1)))
+                : 0);
+           dest_buffer
+             |= (((* (DEC_BIT_STRING_PTR (source))) & (LOW_MASK (head)))
+                 << offset1);
          }
          nbits -= head;
          while (nbits >= OBJECT_LENGTH)