fix for window title and checking array size

This commit is contained in:
programmer10110 2020-09-30 13:42:56 +03:00
parent c95c91a54a
commit 7c42e969d1
1 changed files with 4 additions and 0 deletions

View File

@ -93,6 +93,9 @@ func (p *CameraProcessor) ReadQR() ([]byte, error) {
if cap(chunks) == 0 {
chunks = make([]*chunk, decodedChunk.Total)
}
if decodedChunk.Index > decodedChunk.Total {
return nil, fmt.Errorf("invalid QR-code chunk")
}
if chunks[decodedChunk.Index] != nil {
continue
}
@ -103,6 +106,7 @@ func (p *CameraProcessor) ReadQR() ([]byte, error) {
break
}
}
window.SetWindowTitle("QR-code chunks successfully read!")
data := make([]byte, 0)
for _, c := range chunks {
data = append(data, c.Data...)