Mercurial > hg-stable
changeset 15222:73015301db86
bdiff: fix pointer aliasing
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 11 Oct 2011 20:21:13 -0500 |
parents | 269374b89b74 |
children | fc035e5370ca |
files | mercurial/bdiff.c |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bdiff.c Tue Oct 11 08:32:04 2011 -0500 +++ b/mercurial/bdiff.c Tue Oct 11 20:21:13 2011 -0500 @@ -366,11 +366,11 @@ static PyObject *bdiff(PyObject *self, PyObject *args) { - char *sa, *sb; + char *sa, *sb, *rb; PyObject *result = NULL; struct line *al, *bl; struct hunk l, *h; - char encode[12], *rb; + uint32_t encode[3]; int an, bn, len = 0, la, lb, count; if (!PyArg_ParseTuple(args, "s#s#:bdiff", &sa, &la, &sb, &lb)) @@ -407,9 +407,9 @@ for (h = l.next; h; h = h->next) { if (h->a1 != la || h->b1 != lb) { len = bl[h->b1].l - bl[lb].l; - *(uint32_t *)(encode) = htonl(al[la].l - al->l); - *(uint32_t *)(encode + 4) = htonl(al[h->a1].l - al->l); - *(uint32_t *)(encode + 8) = htonl(len); + encode[0] = htonl(al[la].l - al->l); + encode[1] = htonl(al[h->a1].l - al->l); + encode[2] = htonl(len); memcpy(rb, encode, 12); memcpy(rb + 12, bl[lb].l, len); rb += 12 + len;