diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2020-12-26 16:53:48 +0100 |
---|---|---|
committer | Erik Dubbelboer <erik@dubbelboer.com> | 2020-12-26 16:53:48 +0100 |
commit | 4e63057c0fd0ebcc9040c161ad69c7e56d57cf82 (patch) | |
tree | 0005e491ad96ea940e27f3ff64b822e333e60c93 /args.go | |
parent | fix issue #875 (#909) (diff) | |
download | fasthttp-4e63057c0fd0ebcc9040c161ad69c7e56d57cf82.tar.gz fasthttp-4e63057c0fd0ebcc9040c161ad69c7e56d57cf82.tar.bz2 fasthttp-4e63057c0fd0ebcc9040c161ad69c7e56d57cf82.zip |
Make argsKV more predictable
Fixes #932
Diffstat (limited to 'args.go')
-rw-r--r-- | args.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -361,7 +361,13 @@ func visitArgs(args []argsKV, f func(k, v []byte)) { func copyArgs(dst, src []argsKV) []argsKV { if cap(dst) < len(src) { tmp := make([]argsKV, len(src)) + dst = dst[:cap(dst)] // copy all of dst. copy(tmp, dst) + for i := len(dst); i < len(tmp); i++ { + // Make sure nothing is nil. + tmp[i].key = []byte{} + tmp[i].value = []byte{} + } dst = tmp } n := len(src) @@ -442,7 +448,9 @@ func allocArg(h []argsKV) ([]argsKV, *argsKV) { if cap(h) > n { h = h[:n+1] } else { - h = append(h, argsKV{}) + h = append(h, argsKV{ + value: []byte{}, + }) } return h, &h[n] } |