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) {
11781178 assert .True (t , ok )
11791179 f .tempFiles .Store (defaultXMLPathSharedStrings , "" )
11801180 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 ))
11811184 // Cleanup undelete temporary files
11821185 assert .NoError (t , os .Remove (tempFile .(string )))
11831186 // 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 {
355355 return strconv .Itoa (index )
356356 }
357357 offsetRange := f .sharedStringItem [index ]
358+ if len (offsetRange ) != 2 || offsetRange [0 ] >= offsetRange [1 ] {
359+ return strconv .Itoa (index )
360+ }
358361 buf := make ([]byte , offsetRange [1 ]- offsetRange [0 ])
359362 if _ , err := f .sharedStringTemp .ReadAt (buf , int64 (offsetRange [0 ])); err != nil {
360363 return strconv .Itoa (index )
You can’t perform that action at this time.
0 commit comments