diff --git a/hw/arm/ipod_touch_sha1.c b/hw/arm/ipod_touch_sha1.c index 09e8d6e0dc0bd..6c07bbdf887a9 100644 --- a/hw/arm/ipod_touch_sha1.c +++ b/hw/arm/ipod_touch_sha1.c @@ -52,7 +52,9 @@ static uint64_t s5l8900_sha1_read(void *opaque, hwaddr offset, unsigned size) //fprintf(stderr, "Hash out %08x\n", *(uint32_t *)&s->hashout[offset - 0x20]); if(!s->hash_computed) { // lazy compute the final hash by inspecting the last eight bytes of the buffer, which contains the length of the input data. - uint64_t data_length = swapLong(((uint64_t *)s->buffer)[s->buffer_ind / 8 - 1]) / 8; + uint64_t val = ((uint64_t *)s->buffer)[s->buffer_ind / 8 - 1]; + uint64_t data_length = swapLong(&val) / 8; + SHA_CTX ctx; SHA1_Init(&ctx);