pod: add barrier around memcpy

We need to be sure that the compiler does not perform invented loads
after we checked the pod size. Otherwise we could have found that the
size was ok, only to be overwritten by an invalid size.

One way of avoiding this is to surround the memcpy with a barrier.

See #4822
This commit is contained in:
Wim Taymans 2025-07-30 18:10:09 +02:00
parent 6d07eaea1f
commit abcf70538d
2 changed files with 7 additions and 0 deletions

View file

@ -242,6 +242,7 @@ struct spa_fraction {
#define SPA_UNUSED __attribute__ ((unused))
#define SPA_NORETURN __attribute__ ((noreturn))
#define SPA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
#define SPA_BARRIER __asm__ __volatile__("": : :"memory")
#else
#define SPA_PRINTF_FUNC(fmt, arg1)
#define SPA_FORMAT_ARG_FUNC(arg1)
@ -252,6 +253,7 @@ struct spa_fraction {
#define SPA_UNUSED
#define SPA_NORETURN
#define SPA_WARN_UNUSED_RESULT
#define SPA_BARRIER
#endif
#ifndef SPA_API_IMPL