OSSP CVS Repository

ossp - Check-in [2174]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2174
Date: 2002-May-29 12:21:33 (local)
2002-May-29 10:21:33 (UTC)
User:thl
Branch:
Comment: not setting free()d resources to 0/NULL caused segfaults
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp_msg.c      1.26 -> 1.27     7 inserted, 7 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp_msg.c 1.26 -> 1.27

--- lmtp2nntp_msg.c      2002/05/28 14:17:23     1.26
+++ lmtp2nntp_msg.c      2002/05/29 10:21:33     1.27
@@ -488,16 +488,21 @@
             free(hdC->data.m[i]);
         }
         free (hdC->data.m);
+        hdC->ndata = 0;
     } else
-    if (hdC->ndata == 1)
+    if (hdC->ndata == 1) {
         if (hdC->data.s != NULL)
             free(hdC->data.s);
+        hdC->ndata = 0;
+    }
 }
 
 static void headernamedestroy(headerdata_t *hdC)
 {
-    if (hdC->name != NULL)
+    if (hdC->name != NULL) {
         free(hdC->name);
+        hdC->name = NULL;
+    }
 }
 
 static void headerdestroy(headerdata_t *hdC)
@@ -993,7 +998,6 @@
                             logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - emtpy headername");
                             headerdatadestroy(hdNew);
                             headernamedestroy(hdNew);
-                            hdNew->ndata = 0;
                         }
                         else {
                             hdNew->name = res_ptr;
@@ -1003,7 +1007,6 @@
                         logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - empty headervalue before expansion");
                         headerdatadestroy(hdNew);
                         headernamedestroy(hdNew);
-                        hdNew->ndata = 0;
                     }
                     else {
                         /* expanding regex references into header value */
@@ -1028,7 +1031,6 @@
                                 logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - empty headervalue after expansion");
                                 headerdatadestroy(hdNew);
                                 headernamedestroy(hdNew);
-                                hdNew->ndata = 0;
                             }
                             else {
                                 hdNew->data.s = res_ptr;
@@ -1051,7 +1053,6 @@
                 logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted");
                 headerdatadestroy(hdNew);
                 headernamedestroy(hdNew);
-                hdNew->ndata = 0;
             }
             else {
                 /* expanding variables into header value */
@@ -1065,7 +1066,6 @@
                     logbook(ctx->l2, L2_LEVEL_DEBUG, "marking deleted - empty headervalue after expansion");
                     headerdatadestroy(hdNew);
                     headernamedestroy(hdNew);
-                    hdNew->ndata = 0;
                 }
                 else {
                     headerdatadestroy(hdNew);

CVSTrac 2.0.1