diff --git a/contrib/scripts/get_mp3_source.sh b/contrib/scripts/get_mp3_source.sh
index e1ee13bbdd44d657f053004938adcfdac256e08c..860e2bc02fe20be7da6dee760565e66819236342 100755
--- a/contrib/scripts/get_mp3_source.sh
+++ b/contrib/scripts/get_mp3_source.sh
@@ -17,8 +17,10 @@ fi
 
 svn export http://svn.digium.com/svn/thirdparty/mp3/trunk addons/mp3 $@
 
-# Manually patch interface.c.
-sed -i -e '/#include "asterisk.h"/i#define WRAP_LIBC_MALLOC' \
-    addons/mp3/interface.c
+# Manually patch interface.c if not done yet.
+if ! grep -q WRAP_LIBC_MALLOC addons/mp3/interface.c; then
+    sed -i -e '/#include "asterisk.h"/i#define WRAP_LIBC_MALLOC' \
+        addons/mp3/interface.c
+fi
 
 exit 0