Prevent dangerous bug

In the non-x86 version of memcopy, the lack of braces made seemingly conditional statements run unconditionally, potentially causing segfaults.
This commit is contained in:
pmttavara 2018-02-14 22:35:01 -05:00 committed by GitHub
parent cf7d2e06ee
commit f5094be285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

9
gb.h
View File

@ -3798,13 +3798,16 @@ gb_inline void *gb_memcopy(void *dest, void const *source, isize n) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
} }
if (n & 4) if (n & 4) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
if (n & 2) }
if (n & 2) {
*d++ = *s++; *d++ = *s++; *d++ = *s++; *d++ = *s++;
if (n & 1) }
if (n & 1) {
*d = *s; *d = *s;
} }
}
#endif #endif
return dest; return dest;