[libvirt] [PATCH 1/3] libxl_conf: Resolve Coverity issue with call to regcomp()

John Ferlan jferlan at redhat.com
Tue Mar 5 12:43:11 UTC 2013


---
 src/libxl/libxl_conf.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4ce5dec..b208dd8 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -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",
-- 
1.8.1.2




More information about the libvir-list mailing list