OSSP CVS Repository

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

Check-in Number: 3214
Date: 2003-Feb-11 13:54:58 (local)
2003-Feb-11 12:54:58 (UTC)
User:thl
Branch:
Comment: fix memory leak when overriding a hardcoded default assignemnt
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/lmtp2nntp_option.c      1.28 -> 1.29     8 inserted, 2 deleted

ossp-pkg/lmtp2nntp/lmtp2nntp_option.c 1.28 -> 1.29

--- lmtp2nntp_option.c   2003/02/11 11:40:12     1.28
+++ lmtp2nntp_option.c   2003/02/11 12:54:58     1.29
@@ -378,10 +378,16 @@
         case OPT_SINGLE:
             if (arg == NULL)
                 return OPTION_ERR_ARG;
-        /*  add this if repeated overwriting definitions of single values are not allowed
-         *  if (oc->ndata >= 1 || oc->data.s != NULL)
+        /*  add this if repeated overwriting definitions of single values is not allowed
+         *  however, this will inhibit preinitialization with a default value
+         *  if (oc->ndata != 0)
          *      return OPTION_ERR_USE;
          */
+            if (oc->ndata == 1 && oc->data.s != NULL) { /* free previous (default) assignment */
+                free(oc->data.s);
+                oc->data.s = NULL;
+                oc->ndata = 0;
+            }
             if (cbctx != NULL)
                 if (str_parse(arg, cbctx) <= 0) {
                     fprintf(stderr, "ERROR: argument \"%s\" does NOT match syntax \"%s\"\n", arg, cbctx);

CVSTrac 2.0.1