[libvirt PATCH 2/2] conf: virsecretobj: fix g_new0 allocation

Laine Stump laine at laine.org
Mon Oct 12 20:52:08 UTC 2020


On 10/12/20 2:13 PM, Pavel Hrdina wrote:
> Fixes commit <d5b05614dfbc9bd60ea1a31a9cc32aaf3c771ddc> which changed
> allocation from VIR_ALLOC_N to g_new0 but missed one +1 on number of
> allocated elements.
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
>   src/conf/virsecretobj.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
> index c98d52f1e4..d74deb9316 100644
> --- a/src/conf/virsecretobj.c
> +++ b/src/conf/virsecretobj.c
> @@ -588,7 +588,7 @@ virSecretObjListExport(virConnectPtr conn,
>   
>       virObjectRWLockRead(secretobjs);
>       if (secrets)
> -        data.secrets = g_new0(virSecretPtr, virHashSize(secretobjs->objs));
> +        data.secrets = g_new0(virSecretPtr, virHashSize(secretobjs->objs) + 1);
>   
>       virHashForEach(secretobjs->objs, virSecretObjListExportCallback, &data);
>       virObjectRWUnlock(secretobjs);

Reviewed-by: Laine Stump <laine at redhat.com>




More information about the libvir-list mailing list