Merge stage-aosp-master into pi-dev-plus-aosp
am: 3279f7e640

Change-Id: I12fbf8828ffb6805ba2188791905832baf96e753
diff --git a/libFLAC/Android.bp b/libFLAC/Android.bp
index d1b51f1..1b9c7bd 100644
--- a/libFLAC/Android.bp
+++ b/libFLAC/Android.bp
@@ -51,9 +51,10 @@
     },
 
     sanitize: {
-        cfi: true,
-        diag: {
-            cfi: true,
-        },
+        integer_overflow: true,
+        misc_undefined: ["bounds"],
+        // Enable CFI if this is used as a shared library
+        // cfi: true,
+        blacklist: "libFLAC_blacklist.txt",
     },
 }
diff --git a/libFLAC/fixed.c b/libFLAC/fixed.c
index 1e2d5b2..ed9f498 100644
--- a/libFLAC/fixed.c
+++ b/libFLAC/fixed.c
@@ -166,7 +166,7 @@
 	bits = FLAC__bitmath_ilog2_wide(err)+1;
 	if(bits > 16) {
 		err >>= (bits-16);
-		fracbits -= (bits-16);
+		fracbits -= (int)(bits-16); // defined, but cast to int to avoid ubsan assert.
 	}
 	rbps = (FLAC__uint32)err;
 
diff --git a/libFLAC/libFLAC_blacklist.txt b/libFLAC/libFLAC_blacklist.txt
new file mode 100644
index 0000000..7dff751
--- /dev/null
+++ b/libFLAC/libFLAC_blacklist.txt
@@ -0,0 +1,14 @@
+[integer]
+# Preemptive due to: while(lag--)
+fun:FLAC__lpc_compute_autocorrelation
+# libFLAC/stream_encoder.c:3982: 4294967292 + 128 cannot be represented in type 'unsigned int'
+fun:precompute_partition_info_sums_
+
+src:*/libFLAC/crc.c
+src:*/libFLAC/md5.c
+src:*/libFLAC/bitmath.c
+src:*/libFLAC/bitreader.c
+src:*/libFLAC/bitwriter.c
+
+# Performance related
+fun:FLAC__lpc_restore_signal_wide