]> git.ipfire.org Git - thirdparty/libvirt.git/commit
cpu: fix possible crash in getModels
authorPavel Hrdina <phrdina@redhat.com>
Wed, 3 Dec 2014 17:50:16 +0000 (18:50 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 3 Dec 2014 18:17:05 +0000 (19:17 +0100)
commit4a4cff58eff28d5fe7501d9e9a8de8020e5481b6
treeb55f4ebdfcf390382c091dd4d051cd88fa1705ff
parent48a055607c03c7cd0bdb5fc748c591db01fa45ae
cpu: fix possible crash in getModels

Commit 86a15a25 introduced a new cpu driver API 'getModels'. Public API
allow you to pass NULL for models to get only number of existing models.
However the new code will crash with segfault so we have to count with
the possibility that the user wants only the number.

There is also difference in order of the models gathered by this new API
as the old approach was inserting the elements to the end of the array
so we should use 'VIR_APPEND_ELEMENT'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/cpu/cpu_powerpc.c
src/cpu/cpu_x86.c