Skip to content

Commit 60846b9

Browse files
committed
adding error handling to type cast
1 parent ff456d7 commit 60846b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

store/file/filestore.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ func (store *fileStore) getMessage(seqNum int) (msg []byte, found bool, err erro
365365
if !found {
366366
return
367367
}
368-
msgInfo := msgInfoTemp.(msgDef)
368+
msgInfo, ok := msgInfoTemp.(msgDef)
369+
if !ok {
370+
return nil, true, fmt.Errorf("incorrect msgInfo type while reading file: %s", store.bodyFname)
371+
}
369372

370373
msg = make([]byte, msgInfo.size)
371374
if _, err = store.bodyFile.ReadAt(msg, msgInfo.offset); err != nil {

0 commit comments

Comments
 (0)