[Libvirt-cim] [PATCH] Use strdup() to copy memory so list of strings can be free in Virt_DevicePool

Sharad Mishra snmishra at us.ibm.com
Tue Nov 17 19:27:22 UTC 2009


+1

Sharad Mishra
System x Enablement
Linux Technology Center
IBM


                                                                           
             Kaitlin Rupert                                                
             <kaitlin at linux.vn                                             
             et.ibm.com>                                                To 
             Sent by:                  libvirt-cim at redhat.com              
             libvirt-cim-bounc                                          cc 
             es at redhat.com                                                 
                                                                   Subject 
                                       [Libvirt-cim] [PATCH] Use strdup()  
             11/11/2009 08:06          to copy memory so list of           
             PM                        strings can be free in              
                                       Virt_DevicePool                     
                                                                           
             Please respond to                                             
                 List for                                                  
              discussion and                                               
              development of                                               
                libvirt CIM                                                
             <libvirt-cim at redh                                             
                  at.com>                                                  
                                                                           
                                                                           




# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1257998067 28800
# Node ID 33a6a50f64e08df1585a249d96d89e4e03d663e4
# Parent  a804ea345a48f2dd57a7e78b8fbd595f9397906b
Use strdup() to copy memory so list of strings can be free in
Virt_DevicePool

This were missed in revision 1008.

In Virt_RASD, declare base a const char, as we aren't allocating memory
here.
Revert changes from revision 1008 - this is a regression.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r a804ea345a48 -r 33a6a50f64e0 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c          Fri Nov 06 14:03:41 2009 -0800
+++ b/src/Virt_DevicePool.c          Wed Nov 11 19:54:27 2009 -0800
@@ -130,11 +130,13 @@
         names = calloc(count, sizeof(char *));
         if (names == NULL) {
                 CU_DEBUG("Failed to alloc space for %i pool names",
count);
+                count = 0;
                 goto out;
         }

         if (virConnectListStoragePools(conn, names, count) == -1) {
                 CU_DEBUG("Failed to get storage pools");
+                count = 0;
                 goto out;
         }

@@ -145,7 +147,7 @@
         }

         for (i = 0; i < count; i++) {
-                pools[i].tag = names[i];
+                pools[i].tag = strdup(names[i]);
                 pools[i].primordial = false;
         }

@@ -936,7 +938,7 @@
                 goto out;
         }

-        netnames[nets - 1] = "0";
+        netnames[nets - 1] = strdup("0");

         for (i = 0; i < nets; i++) {
                 _netpool_for_network(list,
diff -r a804ea345a48 -r 33a6a50f64e0 src/Virt_RASD.c
--- a/src/Virt_RASD.c          Fri Nov 06 14:03:41 2009 -0800
+++ b/src/Virt_RASD.c          Wed Nov 11 19:54:27 2009 -0800
@@ -377,7 +377,7 @@
         CMPIStatus s;
         CMPIInstance *inst;
         uint16_t type;
-        char *base;
+        const char *base;
         char *id;
         const char *keys[] = {"InstanceID", NULL};

@@ -407,8 +407,6 @@
                                   CLASSNAME(ref),
                                   base,
                                   NAMESPACE(ref));
-        free(base);
-
         if (inst == NULL)
                 return inst;


_______________________________________________
Libvirt-cim mailing list
Libvirt-cim at redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/dffb5a69/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/dffb5a69/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic02164.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/dffb5a69/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/dffb5a69/attachment-0002.gif>


More information about the Libvirt-cim mailing list