summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
authorMartin Martinez Rivera <mrtnz.rvr@gmail.com>2022-11-04 21:41:07 -0700
committerGitHub <noreply@github.com>2022-11-05 12:41:07 +0800
commit75c912ca952bf47bbe421030554ef580ff4f3996 (patch)
tree227d6e6db5c33fb3e298ac3fa75f9a1df96ede9c /cell.go
parent4998b7b92980e1139b3f38d3c2b8cbc11b1a629d (diff)
This closes #1384, fix segmentation fault in `formattedValue` (#1385)
- Add nil pointer guard in cell format - Add tests to verify the nil checks in formattedValue Co-authored-by: Zach Clark <zachmclark@gmail.com>
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cell.go b/cell.go
index eb60441..ebf4681 100644
--- a/cell.go
+++ b/cell.go
@@ -1292,6 +1292,9 @@ func (f *File) formattedValue(s int, v string, raw bool) string {
return v
}
styleSheet := f.stylesReader()
+ if styleSheet.CellXfs == nil {
+ return v
+ }
if s >= len(styleSheet.CellXfs.Xf) {
return v
}
@@ -1306,7 +1309,7 @@ func (f *File) formattedValue(s int, v string, raw bool) string {
if ok := builtInNumFmtFunc[numFmtID]; ok != nil {
return ok(v, builtInNumFmt[numFmtID], date1904)
}
- if styleSheet == nil || styleSheet.NumFmts == nil {
+ if styleSheet.NumFmts == nil {
return v
}
for _, xlsxFmt := range styleSheet.NumFmts.NumFmt {