swscale/utils: check mprotect() return code
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Oct 2013 08:14:05 +0000 (10:14 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Oct 2013 08:14:05 +0000 (10:14 +0200)
Found-by: wm4
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswscale/utils.c

index 9b2b5e9..0743ee3 100644 (file)
@@ -1430,8 +1430,11 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
                                 c->hChrFilter, (uint32_t*)c->hChrFilterPos, 4);
 
 #if USE_MMAP
-            mprotect(c->lumMmxextFilterCode, c->lumMmxextFilterCodeSize, PROT_EXEC | PROT_READ);
-            mprotect(c->chrMmxextFilterCode, c->chrMmxextFilterCodeSize, PROT_EXEC | PROT_READ);
+            if (   mprotect(c->lumMmxextFilterCode, c->lumMmxextFilterCodeSize, PROT_EXEC | PROT_READ) == -1
+                || mprotect(c->chrMmxextFilterCode, c->chrMmxextFilterCodeSize, PROT_EXEC | PROT_READ) == -1) {
+                av_log(c, AV_LOG_ERROR, "mprotect failed, cannot use fast bilinear scaler\n");
+                goto fail;
+            }
 #endif
         } else
 #endif /* HAVE_MMXEXT_INLINE */