]> Cypherpunks repositories - gostls13.git/commit
regexp: fix index panic in Replace
authorErik St. Martin <alakriti@gmail.com>
Sat, 22 Dec 2012 16:14:56 +0000 (11:14 -0500)
committerRuss Cox <rsc@golang.org>
Sat, 22 Dec 2012 16:14:56 +0000 (11:14 -0500)
commit54b7ccd514f6a689347c8d1f876bec90613f28f8
tree2afc12514a10da1d0150506c0cacc38ce013e14e
parent90a85dbefcc7047eaa0a4466a344a6457b856b74
  regexp: fix index panic in Replace

When using subexpressions ($1) as replacements, when they either don't exist or values weren't found causes a panic.
This patch ensures that the match location isn't -1, to prevent out of bounds errors.
Fixes #3816.

R=franciscossouza, rsc
CC=golang-dev
https://golang.org/cl/6931049
src/pkg/regexp/all_test.go
src/pkg/regexp/regexp.go