Explorar o código

Implement the fix for a file with no sharedStrings.xml as proposed by
HeinOldewage.

Geoffrey J. Teale %!s(int64=11) %!d(string=hai) anos
pai
achega
0f709e079c
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      lib.go

+ 7 - 0
lib.go

@@ -629,6 +629,13 @@ func readSharedStringsFromZipFile(f *zip.File) ([]string, error) {
 	var rc io.ReadCloser
 	var decoder *xml.Decoder
 	var reftable []string
+
+	// In a file with no strings it's possible that
+	// sharedStrings.xml doesn't exist.  In this case the value
+	// passed as f will be nil.
+	if f == nil {
+		return make([]string,0), nil
+	}
 	rc, error = f.Open()
 	if error != nil {
 		return nil, error