Author: eadler (ports committer)
Date: Tue Jan 10 01:01:57 2012
New Revision: 229899
URL: http://svn.freebsd.org/changeset/base/229899

Log:
  - Remove extraneous null ptr deref checks
  - Fix memory leak
  
  Approved by:  jhb

Modified:
  stable/9/usr.sbin/fwcontrol/fwcontrol.c
  stable/9/usr.sbin/newsyslog/newsyslog.c
  stable/9/usr.sbin/ypserv/yp_main.c
Directory Properties:
  stable/9/usr.sbin/fwcontrol/   (props changed)
  stable/9/usr.sbin/newsyslog/   (props changed)
  stable/9/usr.sbin/ypserv/   (props changed)

Modified: stable/9/usr.sbin/fwcontrol/fwcontrol.c
==============================================================================
--- stable/9/usr.sbin/fwcontrol/fwcontrol.c     Tue Jan 10 00:48:29 2012        
(r229898)
+++ stable/9/usr.sbin/fwcontrol/fwcontrol.c     Tue Jan 10 01:01:57 2012        
(r229899)
@@ -152,8 +152,7 @@ str2node(int fd, const char *nodestr)
                fweui2eui64(&data->dev[i].eui, &tmpeui);
                if (memcmp(&eui, &tmpeui, sizeof(struct eui64)) == 0) {
                        node = data->dev[i].dst;
-                       if (data != NULL)
-                               free(data);
+                       free(data);
                        goto gotnode;
                }
        }

Modified: stable/9/usr.sbin/newsyslog/newsyslog.c
==============================================================================
--- stable/9/usr.sbin/newsyslog/newsyslog.c     Tue Jan 10 00:48:29 2012        
(r229898)
+++ stable/9/usr.sbin/newsyslog/newsyslog.c     Tue Jan 10 01:01:57 2012        
(r229899)
@@ -1946,9 +1946,10 @@ do_zipwork(struct zipwork_entry *zwork)
        char zresult[MAXPATHLEN];
        int c;
 
+       assert(zwork != NULL);
        pgm_path = NULL;
        strlcpy(zresult, zwork->zw_fname, sizeof(zresult));
-       if (zwork != NULL && zwork->zw_conf != NULL &&
+       if (zwork->zw_conf != NULL &&
            zwork->zw_conf->compress > COMPRESS_NONE)
                for (c = 1; c < COMPRESS_TYPES; c++) {
                        if (zwork->zw_conf->compress == c) {

Modified: stable/9/usr.sbin/ypserv/yp_main.c
==============================================================================
--- stable/9/usr.sbin/ypserv/yp_main.c  Tue Jan 10 00:48:29 2012        
(r229898)
+++ stable/9/usr.sbin/ypserv/yp_main.c  Tue Jan 10 01:01:57 2012        
(r229899)
@@ -255,6 +255,7 @@ create_service(const int sock, const str
        const struct __rpc_sockinfo *si)
 {
        int error;
+       char *sname;
 
        SVCXPRT *transp;
        struct addrinfo hints, *res, *res0;
@@ -262,6 +263,7 @@ create_service(const int sock, const str
        struct bindaddrlistent *blep;
        struct netbuf svcaddr;
 
+       sname = NULL;
        SLIST_INIT(&sle_head);
        memset(&hints, 0, sizeof(hints));
        memset(&svcaddr, 0, sizeof(svcaddr));
@@ -341,7 +343,6 @@ create_service(const int sock, const str
                                if (strncmp("0", servname, 1) == 0) {
                                        struct sockaddr *sap;
                                        socklen_t slen;
-                                       char *sname;
 
                                        sname = malloc(NI_MAXSERV);
                                        if (sname == NULL) {
@@ -361,6 +362,7 @@ create_service(const int sock, const str
                                                    strerror(errno));
                                                freeaddrinfo(res0);
                                                close(s);
+                                               free(sname);
                                                return -1;
                                        }
                                        error = getnameinfo(sap, slen,
@@ -372,6 +374,7 @@ create_service(const int sock, const str
                                                    strerror(errno));
                                                freeaddrinfo(res0);
                                                close(s);
+                                               free(sname);
                                                return -1;
                                        }
                                        servname = sname;
@@ -440,7 +443,7 @@ create_service(const int sock, const str
        }
        /* XXX: ignore error intentionally */
        rpcb_set(YPPROG, YPVERS, nconf, &svcaddr);
-
+       free(sname);
        freeaddrinfo(res0);
        return 0;
 }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to