strings: negative Repeat count
bang9211 opened this issue · 1 comments
bang9211 commented
When I tried to run the below code, panic is occured
package main
import "github.com/go-xmlfmt/xmlfmt"
func main() {
msg := `<!-- 무조건 착신전환 조회 -->
<?xml version="1.0" encoding="utf-8"?>
<message name="DIS_USER_SSVC" tid="1591918441">
<!-- 결과 코드 : 0(성공) / 그 외(실패) -->
<Result>0</Result>
<parameter>
<SsvcList>
<!-- 가입/사용 여부 : 3(가입+사용 중) / 2(가입+미사용) -->
<CFU>2</CFU>
<!-- 착신 번호(CFU 가 3인 경우 사용) -->
<!-- <DATA>0261216281</DATA> -->
</SsvcList>
</parameter>
</message>`
xmlfmt.FormatXML(string(msg), "", "\t")
}
the error trace is
panic: strings: negative Repeat count
goroutine 1 [running]:
strings.Repeat({0x102cb4c14, 0x1}, 0xffffffffffffffff)
/usr/local/go/src/strings/strings.go:529 +0x41c
github.com/go-xmlfmt/xmlfmt.replaceTag.func1({0x1400011e195, 0xa})
/Users/hanyoungtak/Documents/go/pkg/mod/github.com/go-xmlfmt/xmlfmt@v0.0.0-20191208150333-d5b6f63a941b/xmlfmt.go:48 +0x24c
regexp.(*Regexp).ReplaceAllStringFunc.func1({0x1400011c300, 0x1cd, 0x300}, {0x14000016240, 0x2, 0x2})
/usr/local/go/src/regexp/regexp.go:596 +0x78
regexp.(*Regexp).replaceAll(0x1400007c0a0, {0x0, 0x0, 0x0}, {0x1400011e000, 0x19f}, 0x2, 0x14000105e98)
/usr/local/go/src/regexp/regexp.go:634 +0x314
regexp.(*Regexp).ReplaceAllStringFunc(0x1400007c0a0, {0x1400011e000, 0x19f}, 0x14000068210)
/usr/local/go/src/regexp/regexp.go:595 +0x74
github.com/go-xmlfmt/xmlfmt.FormatXML({0x102cbacae, 0x1cf}, {0x0, 0x0}, {0x102cb4c14, 0x1})
/Users/hanyoungtak/Documents/go/pkg/mod/github.com/go-xmlfmt/xmlfmt@v0.0.0-20191208150333-d5b6f63a941b/xmlfmt.go:25 +0xc4
main.main()
/Users/hanyoungtak/Documents/go/src/xml-test/main.go:20 +0x4c
AntonioSun commented
fixed. see #2