diff options
author | Kevin McCarthy <kevin@8t8.us> | 2019-09-30 18:50:27 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2019-09-30 19:01:59 -0700 |
commit | a6bccbe1d1b731e69b2b609278ef0811d547a6e7 (patch) | |
tree | b949e1bddce29d8dfb43da6d12f06b57e6fae54e /imap/util.c | |
parent | fb1686b66f028e0c844b3bb828c2882a3b8c0673 (diff) |
Memcpy header cache fetch values to ensure alignment.
While testing the hcache buffer pool changes, I noticed a misaligned
pointer warning when using LMDB.
The other header cache backends must ensure alignment of the pointer
they return, but LMDB apparently does not.
Instead of directly assigning and dereferencing the pointer fetched,
use memcpy to the appropriate type, just as the header cache restore
operation does.
Diffstat (limited to 'imap/util.c')
-rw-r--r-- | imap/util.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/imap/util.c b/imap/util.c index 0812bac3..42f07cc2 100644 --- a/imap/util.c +++ b/imap/util.c @@ -179,22 +179,24 @@ void imap_hcache_close (IMAP_DATA* idata) HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid) { char key[16]; - unsigned int* uv; + void *data; + unsigned int uv; HEADER* h = NULL; if (!idata->hcache) return NULL; sprintf (key, "/%u", uid); - uv = (unsigned int*)mutt_hcache_fetch (idata->hcache, key, - imap_hcache_keylen); - if (uv) + data = mutt_hcache_fetch (idata->hcache, key, + imap_hcache_keylen); + if (data) { - if (*uv == idata->uid_validity) - h = mutt_hcache_restore ((unsigned char*)uv, NULL); + memcpy (&uv, data, sizeof(unsigned int)); + if (uv == idata->uid_validity) + h = mutt_hcache_restore ((unsigned char *)data, NULL); else - dprint (3, (debugfile, "hcache uidvalidity mismatch: %u", *uv)); - mutt_hcache_free ((void **)&uv); + dprint (3, (debugfile, "hcache uidvalidity mismatch: %u", uv)); + mutt_hcache_free ((void **)&data); } return h; |