Fix toJsonClassLoaderContextRec size bug
toJsonClassLoaderContextRec's size is twice as large than expected. And
the initial values is filled with null value.
Bug: 158843648
Test: m nothing(testcase is added)
Change-Id: I24c23269bd16baa18481f34b85c543d41f26d0e0
diff --git a/dexpreopt/class_loader_context.go b/dexpreopt/class_loader_context.go
index ad52b00..f76a205 100644
--- a/dexpreopt/class_loader_context.go
+++ b/dexpreopt/class_loader_context.go
@@ -544,13 +544,13 @@
// Recursive helper for toJsonClassLoaderContext.
func toJsonClassLoaderContextRec(clcs []*ClassLoaderContext) []*jsonClassLoaderContext {
jClcs := make([]*jsonClassLoaderContext, len(clcs))
- for _, clc := range clcs {
- jClcs = append(jClcs, &jsonClassLoaderContext{
+ for i, clc := range clcs {
+ jClcs[i] = &jsonClassLoaderContext{
Name: clc.Name,
Host: clc.Host.String(),
Device: clc.Device,
Subcontexts: toJsonClassLoaderContextRec(clc.Subcontexts),
- })
+ }
}
return jClcs
}