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

buffer is not allocated in client.Read function #12

Open
ozanh opened this issue Jul 18, 2019 · 0 comments
Open

buffer is not allocated in client.Read function #12

ozanh opened this issue Jul 18, 2019 · 0 comments

Comments

@ozanh
Copy link

ozanh commented Jul 18, 2019

Hello,
Thank you for the S7 library. I'd like to report a bug. In the client.Read function, buffer is not allocated in line 383 as below, which causes panic while copying response.Data in client.readArea. I am not sure if it is wise to make var buffer = make([]byte, 255) in client.Read function or changing function signature to pass buffer as a parameter.

gos7/client.go

Lines 374 to 384 in a789e2a

func (mb *client) Read(variable string) (value interface{}, err error) {
variable = strings.ToUpper(variable) //upper
variable = strings.Replace(variable, " ", "", -1) //remove spaces
if variable == "" {
err = fmt.Errorf("input variable is empty, variable should be S7 syntax")
return
}
//var area, dbNumber, start, amount, wordLen int
var buffer []byte
switch valueArea := variable[0:2]; valueArea {

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

1 participant