From 4f3854a9fe6eaa8e088dcc5ba5de40258029b55e Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Thu, 19 Sep 2024 16:42:49 +0200 Subject: [PATCH] fix the nil pointer --- changelog/unreleased/fix-time-convertion.md | 5 +++++ pkg/utils/utils.go | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 changelog/unreleased/fix-time-convertion.md diff --git a/changelog/unreleased/fix-time-convertion.md b/changelog/unreleased/fix-time-convertion.md new file mode 100644 index 0000000000..1c9b6e0806 --- /dev/null +++ b/changelog/unreleased/fix-time-convertion.md @@ -0,0 +1,5 @@ +Bugfix: Fix time conversion + +We fixed a nil pointer in a time conversion + +https://github.com/cs3org/reva/pull/4856 diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 8f97f7be81..77e1c9ef0e 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -146,6 +146,9 @@ func TSToUnixNano(ts *types.Timestamp) uint64 { // TSToTime converts a protobuf Timestamp to Go's time.Time. func TSToTime(ts *types.Timestamp) time.Time { + if ts == nil { + return time.Time{} + } return time.Unix(int64(ts.Seconds), int64(ts.Nanos)) }