0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.0.0183: ubsan warns for unaligned address

Problem:    Ubsan warns for using a pointer that is not aligned.
Solution:   First copy the address. (Yegappan Lakshmanan)
This commit is contained in:
Bram Moolenaar
2017-01-14 17:04:38 +01:00
parent e47683a091
commit 7173b47958
2 changed files with 10 additions and 1 deletions

View File

@@ -710,7 +710,14 @@ channel_open(
channel_free(channel);
return NULL;
}
memcpy((char *)&server.sin_addr, host->h_addr, host->h_length);
{
char *p;
/* When using host->h_addr directly ubsan warns for it to not be
* aligned. First copy the pointer to aviod that. */
memcpy(&p, &host->h_addr, sizeof(p));
memcpy((char *)&server.sin_addr, p, host->h_length);
}
/* On Mac and Solaris a zero timeout almost never works. At least wait
* one millisecond. Let's do it for all systems, because we don't know why