OSDN Git Service

Fix a bug where the max blowup of annotations was incorrect. do not merge.
authorJesse Wilson <jwilson@squareup.com>
Sat, 1 Sep 2012 05:01:05 +0000 (01:01 -0400)
committerXavier Ducrohet <xav@android.com>
Thu, 6 Sep 2012 19:48:35 +0000 (12:48 -0700)
I'm not sure where the 1.34 number comes from but it's incorrect.
From the spec, the encoded_annotation is made up of a single byte
plus an unlimited number of uleb128 values. Each of these values
can double in width in the worst case. I received (personal) email
from one user who'd run into a case worse than the incorrect 1.34
limit.

(cherry picked from commit bf7dfeea94f21dd0e097cf5f786f9995722fd70d)

Change-Id: I033a0d76ea0324d434d732e7757df0c3fd925b68

dx/src/com/android/dx/merge/DexMerger.java

index c48f436..8237bda 100644 (file)
@@ -1011,8 +1011,8 @@ public final class DexMerger {
                 classData += (int) Math.ceil(contents.classDatas.byteCount * 1.34);
                 // all of the bytes in an encoding arrays section may be uleb/sleb
                 encodedArray += contents.encodedArrays.byteCount * 2;
-                // at most 1/3 of the bytes in an encoding arrays section are uleb/sleb
-                annotation += (int) Math.ceil(contents.annotations.byteCount * 1.34);
+                // all of the bytes in an annotations section may be uleb/sleb
+                annotation += (int) Math.ceil(contents.annotations.byteCount * 2);
                 // all of the bytes in a debug info section may be uleb/sleb
                 debugInfo += contents.debugInfos.byteCount * 2;
             }