From: Maria Matejka Date: Wed, 14 Aug 2019 08:28:23 +0000 (+0200) Subject: Not calling memcpy with n=0. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=531e0359d74db98545cbfc1b87a503e6fe37745c;p=thirdparty%2Fbird.git Not calling memcpy with n=0. --- diff --git a/lib/string.h b/lib/string.h index 0d34f9c57..380133945 100644 --- a/lib/string.h +++ b/lib/string.h @@ -60,6 +60,15 @@ memset32(void *D, u32 val, uint n) dst[i] = val; } +static inline void * +bmemcpy(void *dest, const void *src, size_t n) +{ + if (n) + return memcpy(dest, src, n); + else + return dest; +} + #define ROUTER_ID_64_LENGTH 23 #endif diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index 0fcce8783..fefcf9701 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -495,7 +495,7 @@ static inline void bgp_set_attr_data(ea_list **to, struct linpool *pool, uint code, uint flags, void *data, uint len) { struct adata *a = lp_alloc_adata(pool, len); - memcpy(a->data, data, len); + bmemcpy(a->data, data, len); bgp_set_attr(to, pool, code, flags, (uintptr_t) a); }