[PATCH] Remove another if (E != NULL) check around free(E)

Alan Coopersmith alan.coopersmith at oracle.com
Tue Nov 29 21:44:47 PST 2011


On 11/29/11 20:52, Matt Turner wrote:
> I wonder if there are any other patterns we haven't seen yet?

Are you sure you want to know the answer to that?

server/hw/kdrive/ephyr/ephyrhostvideo.c:

void
ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
                           int a_num_encodings)
{
     int i=0 ;

     if (!a_encodings)
         return ;
     for (i=0; i < a_num_encodings; i++) {
         free(a_encodings[i].name) ;
         a_encodings[i].name = NULL ;
     }
     free(a_encodings) ;
}

void
ephyrHostAttributesDelete (EphyrHostAttribute *a_attributes)
{
     if (!a_attributes)
         return ;
     XFree (a_attributes) ;
}


xserver/hw/dmx/config/dmxconfig.c:

#define GEN(param,glob,def)                                                   \
  void dmxConfigSet##glob(const char *param) {                                 \
      if (dmx##glob) free((void *)dmx##glob);                                  \
      dmx##glob = strdup(param);                                               \
  }


xserver/hw/xfree86/parser/Configint.h:

#define TestFree(a) if (a) { free (a); a = NULL; }


xserver/hw/xfree86/xaa/xaaCpyArea.c:

                 if (pboxNew1) {
                     free(pptNew1);
                     free(pboxNew1);
                 }
[...]
     if (pboxNew2) {
         free(pptNew2);
         free(pboxNew2);
     }
     if (pboxNew1) {
         free(pptNew1);
         free(pboxNew1);
     }

xserver/xkb/xkbUtils.c:

                     if (dtype->map && dtype->map_count)
                         free(dtype->map);
                     if (dtype->preserve && dtype->map_count)
                         free(dtype->preserve);

xserver/xkb/xkb.c:

         else if (names->radio_groups) {
             free(names->radio_groups);
             names->radio_groups= NULL;
             names->num_rg= 0;
         }

[...]
     if (start!=NULL)
         free((char *)start);

(Doesn't mean any are worth worrying about, just that they're out there.)

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list