Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strings: negative Repeat count #3

Closed
bang9211 opened this issue Dec 6, 2021 · 1 comment
Closed

strings: negative Repeat count #3

bang9211 opened this issue Dec 6, 2021 · 1 comment

Comments

@bang9211
Copy link

bang9211 commented Dec 6, 2021

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
Copy link
Contributor

fixed. see #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants