veyron.io/veyron/veyron/lib/stats/sysstats: Bugfix for android.
Detailed note: when the environment variable has more or less than two arguments, the "kv" array will have the default assigned value of nil, which would panic the Set() method below.
Change-Id: I15038dac45384862cb304b001d2c9390cb044174
Fix: don't pre-size the array.
diff --git a/lib/stats/sysstats/sysstats.go b/lib/stats/sysstats/sysstats.go
index ead2de1..a952cd5 100644
--- a/lib/stats/sysstats/sysstats.go
+++ b/lib/stats/sysstats/sysstats.go
@@ -29,10 +29,10 @@
}
func exportEnv() {
- kv := make([]stats.KeyValue, len(os.Environ()))
- for i, v := range os.Environ() {
+ var kv []stats.KeyValue
+ for _, v := range os.Environ() {
if parts := strings.SplitN(v, "=", 2); len(parts) == 2 {
- kv[i] = stats.KeyValue{parts[0], parts[1]}
+ kv = append(kv, stats.KeyValue{parts[0], parts[1]})
}
}
stats.NewMap("system/environ").Set(kv)