]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl_conf: Resolve Coverity issue with call to regcomp()
authorJohn Ferlan <jferlan@redhat.com>
Thu, 28 Feb 2013 14:46:34 +0000 (09:46 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 6 Mar 2013 03:52:51 +0000 (22:52 -0500)
src/libxl/libxl_conf.c

index 4ce5deceee90764678ffe5da151beed8161e1e88..b208dd8fb112d4b3a150778e8deeaba65f2df99a 100644 (file)
@@ -769,10 +769,19 @@ error:
 virCapsPtr
 libxlMakeCapabilities(libxl_ctx *ctx)
 {
+    int err;
     libxl_physinfo phy_info;
     const libxl_version_info *ver_info;
 
-    regcomp(&xen_cap_rec, xen_cap_re, REG_EXTENDED);
+    err = regcomp(&xen_cap_rec, xen_cap_re, REG_EXTENDED);
+    if (err != 0) {
+        char error[100];
+        regerror(err, &xen_cap_rec, error, sizeof(error));
+        regfree(&xen_cap_rec);
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to compile regex %s"), error);
+        return NULL;
+    }
 
     if (libxl_get_physinfo(ctx, &phy_info) != 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",