[FFmpeg-devel] [PATCH 7/7] avutil/mem: Assert that the FPU state is clean before calling libc *alloc() / free()
Michael Niedermayer
michael at niedermayer.cc
Fri Oct 21 16:31:46 EEST 2016
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavutil/mem.c | 7 +++++++
libavutil/mem_internal.h | 2 ++
2 files changed, 9 insertions(+)
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 1a8fc21..0771fa3 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -81,6 +81,8 @@ void *av_malloc(size_t size)
long diff;
#endif
+ av_assert2_fpu();
+
/* let's disallow possibly ambiguous cases */
if (size > (max_alloc_size - 32))
return NULL;
@@ -148,6 +150,8 @@ void *av_realloc(void *ptr, size_t size)
int diff;
#endif
+ av_assert2_fpu();
+
/* let's disallow possibly ambiguous cases */
if (size > (max_alloc_size - 32))
return NULL;
@@ -227,6 +231,7 @@ int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
void av_free(void *ptr)
{
+ av_assert2_fpu();
#if CONFIG_MEMALIGN_HACK
if (ptr) {
int v= ((char *)ptr)[-1];
@@ -479,6 +484,8 @@ void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
{
+ av_assert2_fpu();
+
if (min_size < *size)
return ptr;
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
index 6fdbcb0..b74febc 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -28,6 +28,8 @@ static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size,
{
void *val;
+ av_assert2_fpu();
+
memcpy(&val, ptr, sizeof(val));
if (min_size <= *size) {
av_assert0(val || !min_size);
--
2.10.1
More information about the ffmpeg-devel
mailing list