From 05798672c87818edc573341d81f15bc91603b689 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 30 Nov 2016 21:05:35 +0000 Subject: [PATCH] acd: Fix nil pointer deref - fixes #916 --- amazonclouddrive/amazonclouddrive.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/amazonclouddrive/amazonclouddrive.go b/amazonclouddrive/amazonclouddrive.go index 95cab7746..5190aa3dc 100644 --- a/amazonclouddrive/amazonclouddrive.go +++ b/amazonclouddrive/amazonclouddrive.go @@ -819,7 +819,7 @@ func (o *Object) Hash(t fs.HashType) (string, error) { if t != fs.HashMD5 { return "", fs.ErrHashUnsupported } - if o.info.ContentProperties.Md5 != nil { + if o.info.ContentProperties != nil && o.info.ContentProperties.Md5 != nil { return *o.info.ContentProperties.Md5, nil } return "", nil @@ -827,7 +827,10 @@ func (o *Object) Hash(t fs.HashType) (string, error) { // Size returns the size of an object in bytes func (o *Object) Size() int64 { - return int64(*o.info.ContentProperties.Size) + if o.info.ContentProperties != nil && o.info.ContentProperties.Size != nil { + return int64(*o.info.ContentProperties.Size) + } + return 0 // Object is likely PENDING } // readMetaData gets the metadata if it hasn't already been fetched @@ -1108,7 +1111,7 @@ OnConflict: // MimeType of an Object if known, "" otherwise func (o *Object) MimeType() string { - if o.info.ContentProperties.ContentType != nil { + if o.info.ContentProperties != nil && o.info.ContentProperties.ContentType != nil { return *o.info.ContentProperties.ContentType } return ""