api: Error checking before NULL dereference

Move error checking of possible null returned value before
its dereference in importBuilder.Format

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru>
This commit is contained in:
Tigran Sogomonian 2024-11-28 14:01:45 +03:00
parent a9b163a757
commit 1fa27ffb62
1 changed files with 1 additions and 1 deletions

View File

@ -72,10 +72,10 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
OverrideConfig: options.CommitOptions.OverrideConfig,
}
importBuilder, err := buildah.ImportBuilder(ctx, c.runtime.store, builderOptions)
importBuilder.Format = options.PreferredManifestType
if err != nil {
return nil, err
}
importBuilder.Format = options.PreferredManifestType
if options.Author != "" {
importBuilder.SetMaintainer(options.Author)
}