changeset 384:a29decbf7475

mpatch: attempt to handle unpack alignment issues on Solaris -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 mpatch: attempt to handle unpack alignment issues on Solaris manifest hash: e185dc380bab61cf11a9973ee3ddd2e904e56299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsnOtywK+sNU5EO8RAlzQAJ9YIhbL8BJjT+J/pOiQVES2wsF0igCgnFRl ok5f8i8GbNk77sRbpsGnUF0= =m0Zh -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 16 Jun 2005 22:54:37 -0800
parents 4862a134e2c2
children e9e1efd5291c
files mercurial/mpatch.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mpatch.c	Thu Jun 16 22:32:55 2005 -0800
+++ b/mercurial/mpatch.c	Thu Jun 16 22:54:37 2005 -0800
@@ -195,15 +195,17 @@
 	struct flist *l;
 	struct frag *lt;
 	char *end = bin + len;
+	char decode[12]; /* for dealing with alignment issues */
 
 	/* assume worst case size, we won't have many of these lists */
 	l = lalloc(len / 12);
 	lt = l->tail;
 
 	while (bin < end) {
-		lt->start = ntohl(*(uint32_t *)bin);
-		lt->end = ntohl(*(uint32_t *)(bin + 4));
-		lt->len = ntohl(*(uint32_t *)(bin + 8));
+		memcpy(decode, bin, 12);
+		lt->start = ntohl(*(uint32_t *)decode);
+		lt->end = ntohl(*(uint32_t *)(decode + 4));
+		lt->len = ntohl(*(uint32_t *)(decode + 8));
 		lt->data = bin + 12;
 		bin += 12 + lt->len;
 		lt++;