Fix faad2 version check, which caused wrong function prototypes to be used and as a result caused stack corruption
diff --git a/debian/changelog b/debian/changelog
index e2d561c..9ccc37a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+gst-plugins-bad1.0 (1.4.5-3) unstable; urgency=medium
+
+  * debian/patches/03_fix-faad2-version-check.patch:
+    + Fix faad2 version check, which caused wrong function prototypes to be
+      used and as a result caused stack corruption (Closes: #797227, #788708).
+
+ -- Sebastian Dröge <slomo@debian.org>  Fri, 04 Sep 2015 16:58:00 +0300
+
 gst-plugins-bad1.0 (1.4.5-2) unstable; urgency=medium
 
   * Upload to unstable.
diff --git a/debian/patches/03_fix-faad2-version-check.patch b/debian/patches/03_fix-faad2-version-check.patch
new file mode 100644
index 0000000..ada775f
--- /dev/null
+++ b/debian/patches/03_fix-faad2-version-check.patch
@@ -0,0 +1,38 @@
+From 1f738ca5b8711ca5532a326cd646312e60484863 Mon Sep 17 00:00:00 2001
+From: Wim Taymans <wtaymans@redhat.com>
+Date: Wed, 13 May 2015 16:23:26 +0200
+Subject: [PATCH] fix faad2 version check
+
+On fedora 22, the output of cpp inserts extra debug comments, which
+makes our regexp for the faad2 version check fail. This in turn causes
+it to compile with the wrong arguments passed which then causes stack
+corruption and crashes.
+
+Fix this by only checking for the version (which should be by itself on
+a single line). This is potentially less safe, it might be possible that
+a similar string would appear in a later version in the header file.
+
+Fixes https://bugzilla.gnome.org/show_bug.cgi?id=748571
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index f5ce28c..d295253 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -2008,9 +2008,9 @@ AG_GST_CHECK_FEATURE(FAAD, [AAC decoder plug-in], faad, [
+       AC_MSG_CHECKING([Checking FAAD2 version in $faad_hdr])
+       for minor in 10 9 8 7 6 5 0; do
+         if test x$faad2_minor_version = "x"; then
+-          AC_EGREP_CPP([GST_CHECK_FAAD_VERSION \"2\.$minor\"], [
++          AC_EGREP_CPP([\"2\.$minor\"$], [
+               #include <$faad_hdr>
+-              GST_CHECK_FAAD_VERSION FAAD2_VERSION
++              FAAD2_VERSION
+             ], [
+               faad2_minor_version=$minor
+             ])
+-- 
+2.5.1
+
diff --git a/debian/patches/series b/debian/patches/series
index 6d98219..570d151 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 01_fix-modplug-linking.patch
 02_opencv-linking.patch
+03_fix-faad2-version-check.patch