File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -1178,6 +1178,9 @@ func TestSharedStringsError(t *testing.T) {
1178
1178
assert .True (t , ok )
1179
1179
f .tempFiles .Store (defaultXMLPathSharedStrings , "" )
1180
1180
assert .Equal (t , "1" , f .getFromStringItem (1 ))
1181
+ // Test get from string item with invalid offset range
1182
+ f .sharedStringItem = [][]uint {{0 }}
1183
+ assert .Equal (t , "0" , f .getFromStringItem (0 ))
1181
1184
// Cleanup undelete temporary files
1182
1185
assert .NoError (t , os .Remove (tempFile .(string )))
1183
1186
// Test reload the file error on set cell value and rich text. The error message was different between macOS and Windows
Original file line number Diff line number Diff line change @@ -355,6 +355,9 @@ func (f *File) getFromStringItem(index int) string {
355
355
return strconv .Itoa (index )
356
356
}
357
357
offsetRange := f .sharedStringItem [index ]
358
+ if len (offsetRange ) != 2 || offsetRange [0 ] >= offsetRange [1 ] {
359
+ return strconv .Itoa (index )
360
+ }
358
361
buf := make ([]byte , offsetRange [1 ]- offsetRange [0 ])
359
362
if _ , err := f .sharedStringTemp .ReadAt (buf , int64 (offsetRange [0 ])); err != nil {
360
363
return strconv .Itoa (index )
You can’t perform that action at this time.
0 commit comments