From 90ac3c2b931d060e918a66047ff76c7d45f2274a Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sun, 14 Oct 2018 22:13:34 +0200
Subject: [PATCH] lavc/sinewin: Do not declare the tables as const.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
At least ff_sine_window_init() is writing to some of the tables causing
a crash if compiled with gcc 8 and lto.
Analyzed by Martin Liška in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85132
Fixes ticket #7491.
---
libavcodec/sinewin.h | 10 ++--------
libavcodec/sinewin_tablegen.h | 2 +-
2 files changed, 3 insertions(+), 9 deletions(-)
@@ -25,18 +25,12 @@
#include "libavutil/mem.h"
#include "libavcodec/aac_defines.h"
-#if CONFIG_HARDCODED_TABLES
-# define SINETABLE_CONST const
-#else
-# define SINETABLE_CONST
-#endif
-
#ifndef USE_FIXED
#define USE_FIXED 0
#endif
#define SINETABLE(size) \
- SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size]
+ DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size]
/**
* Generate a sine window.
@@ -62,6 +56,6 @@ extern SINETABLE(2048);
extern SINETABLE(4096);
extern SINETABLE(8192);
-extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[16];
+extern INTFLOAT * const AAC_RENAME(ff_sine_windows)[16];
#endif /* AVCODEC_SINEWIN_H */
@@ -59,7 +59,7 @@ SINETABLE(8192);
#define SIN_FIX(a) a
#endif
-SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
+INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
NULL, NULL, NULL, NULL, NULL, // unused
AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128),
AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024),
--
1.7.10.4