Commit c17ec950 authored by Mike Frysinger's avatar Mike Frysinger

lib: frame: avoid casting char* to short*

This might end up violating alignment requirements, so memcpy the
variable through a short variable instead.  For most systems, this
will optimize into the same code anyways, and for the rest, we need
to do it this way to avoid unaligned accesses crashing.

URL: https://bugs.gentoo.org/558436
parent b10a1c0f
......@@ -40,8 +40,9 @@
static const char *pr_dlci(const char *ptr)
{
static char buf[12];
snprintf(buf, sizeof(buf), "%i", *(short *) ptr);
short i;
memcpy(&i, ptr, sizeof(i));
snprintf(buf, sizeof(buf), "%i", i);
return (buf);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment