mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
Prevent nil pointer deref in GetImage
Trying to print the image id on a failed inspect will result in a nil pointer panic because the image will be nil. Replace image.id with the image name which is defined as a string without the use of inspect. Fixes: bz#2131836 [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -403,7 +403,7 @@ func GetImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
inspect, err := handlers.ImageDataToImageInspect(r.Context(), newImage)
|
inspect, err := handlers.ImageDataToImageInspect(r.Context(), newImage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("failed to convert ImageData to ImageInspect '%s': %w", inspect.ID, err))
|
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("failed to convert ImageData to ImageInspect '%s': %w", name, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
utils.WriteResponse(w, http.StatusOK, inspect)
|
utils.WriteResponse(w, http.StatusOK, inspect)
|
||||||
|
Reference in New Issue
Block a user