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

-gcflag “-N”参数下编译时中英文混写会panic: runtime error: slice bounds out of range [:5] with capacity 0 #679

Closed
undom opened this issue Aug 3, 2020 · 1 comment

Comments

@undom
Copy link

undom commented Aug 3, 2020

Description
go build 加参数 -gcflag “-N”编译(debug时需要)
使用streamWriter.SetRow(cell, row)时
row中中英文混写(如"模板ID")会panic
研究了下原因
stringToBytes()使用了unssafe包, 在-gcflag “-N”参数下编译运行时会返回[]byte,len>0, cap=0,使用返回的slice时会panic

Steps to reproduce the issue:
1.使用streamWriter.SetRow(“A1”, []interface{}{"模板ID"})
2.go build 带参数-gcflag “-N”
3.构建excel

Describe the results you received:
panic: runtime error: slice bounds out of range [:5] with capacity 0
Describe the results you expected:
no panic
Output of go version:

go version go1.13.9 darwin/amd64

Excelize version or commit ID:

lastest

Environment details (OS, Microsoft Excel™ version, physical, etc.):
mac OS 10.15.4 (19E287)

@xuri
Copy link
Member

xuri commented Aug 6, 2020

Thanks for your feedback, I have fixed it. Please try to upgrade the library with the master branch code.

nullfy pushed a commit to nullfy/excelize that referenced this issue Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants