c8d/history: Fix nil dereference

Check if `Created` is not nil before dereferencing.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-10-24 17:10:12 +02:00
parent 1b9411ef77
commit 27e064e7e9
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -81,11 +81,15 @@ func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*imaget
sizes = sizes[1:]
}
var created int64
if h.Created != nil {
created = h.Created.Unix()
}
history = append([]*imagetype.HistoryResponseItem{{
ID: "<missing>",
Comment: h.Comment,
CreatedBy: h.CreatedBy,
Created: h.Created.Unix(),
Created: created,
Size: size,
Tags: nil,
}}, history...)