From 93a26255074652df0b2f672faa972d85efbfd2b9 Mon Sep 17 00:00:00 2001 From: Evidence John Date: Tue, 7 Dec 2021 21:18:03 +0800 Subject: [PATCH] fix bug: SIGBUS encountered on some platforms --- src/cc_tsrmgr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc_tsrmgr.c b/src/cc_tsrmgr.c index 800177c..c25b253 100644 --- a/src/cc_tsrmgr.c +++ b/src/cc_tsrmgr.c @@ -275,6 +275,7 @@ void cc_tsrmgr_unpack(struct list *tls) struct list *container; cc_uint8 *dptr, *rptr; cc_ssize j, off, len; + rlen_t rlen; cc_usize i; if (!cc_tsrmgr_status()) cc_tsrmgr_init(); @@ -287,7 +288,8 @@ void cc_tsrmgr_unpack(struct list *tls) off = strlen(name) + 1; for (j = 0; j < CC_TENSOR_ITEMS; ++j) { /* Ref: util_list.h */ - len = *(rlen_t*)(rptr + off); + memcpy(&rlen, rptr + off, sizeof(rlen)); + len = rlen; dptr = rptr + off + sizeof(rlen_t); cc_assert_ptr( list_set_data(container, j, dptr, len));