]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86.c: avoid NULL-deref for invalid arguments
authorJim Meyering <meyering@redhat.com>
Tue, 26 Jan 2010 18:58:48 +0000 (19:58 +0100)
committerJim Meyering <meyering@redhat.com>
Wed, 27 Jan 2010 12:39:58 +0000 (13:39 +0100)
* src/cpu/cpu_x86.c (x86Decode): Do not dereference NULL
when "models" is NULL and nmodels is 1 or greater.

src/cpu/cpu_x86.c

index dae7c906a2b88951aeb4b29cd6877d4bb751ef87..47dc400ea5cf2a93425a89f5a8439d7a9cfc107d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * cpu_x86.c: CPU driver for CPUs with x86 compatible CPUID instruction
  *
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -954,6 +954,9 @@ x86Decode(virCPUDefPtr cpu,
     if (data == NULL || (map = x86LoadMap()) == NULL)
         return -1;
 
+    if (models == NULL && nmodels != 0)
+        return -1;
+
     candidate = map->models;
     while (candidate != NULL) {
         bool allowed = (models == NULL);