ossp-pkg/lmtp2nntp/lmtp.c 1.16 -> 1.17
--- lmtp.c 2001/08/27 14:49:32 1.16
+++ lmtp.c 2001/08/28 11:31:22 1.17
@@ -143,10 +143,13 @@
if (lmtp == NULL)
return;
- for (i = 0; (i < LMTP_MAXVERBS) && (lmtp->dispatch[i] != NULL); i++)
- free(lmtp->dispatch[i]); /* lmtp_register() */
- free(lmtp->dispatch); /* lmtp_create() */
- free(lmtp); /* lmtp_create() */
+
+ for (i = 0; (i < LMTP_MAXVERBS) && (lmtp->dispatch[i] != NULL); i++) {
+ free(lmtp->dispatch[i]->verb); /* lmtp_register() */
+ free(lmtp->dispatch[i]); /* lmtp_register() */
+ }
+ free(lmtp->dispatch); /* lmtp_create() */
+ free(lmtp); /* lmtp_create() */
return;
}
@@ -216,7 +219,8 @@
size_t offsetline; /* memorizing start of line when reallocing in the middle of a line */
nBuf = 4096;
- if ((cpBuf = (char *)malloc(nBuf)) == NULL) return LMTP_ERR_MEM;
+ if ((cpBuf = (char *)malloc(nBuf)) == NULL)
+ return LMTP_ERR_MEM;
*cppBuf = cpBuf; /* tell caller about the buffer */
cpPtr = cpBuf; /* initialize write cursor */
cpLine = cpBuf; /* initialize start of line */
@@ -437,9 +441,10 @@
/* Print a welcome message then execute a request/ dispatch loop until
* request signals no more data. Each request is checked to contain a
* registered verb and if a verb is found the correspondig callback is
- * executed. The create() function usually cares to register a default
- * callback in order to handle unregistered verbs. The psoudoverb for
- * default is the empty string "".
+ * executed. The lmtp_create() function usually cares to register a
+ * default callback in order to handle unregistered verbs. The psoudoverb
+ * for default is the empty string "" and the callback for this verb can
+ * be overridden.
*/
lmtp_rc_t rc = LMTP_OK;
lmtp_req_t req;
@@ -447,6 +452,9 @@
char *verb;
int i;
+ req.verb = "";
+ req.msg = NULL;
+
res.statuscode = "220";
res.dsncode = NULL;
res.statusmsg = "LMTP Service ready.";
@@ -457,6 +465,11 @@
verb = req.verb;
if ((i = verbindex(lmtp, verb)) != -1) {
rc = lmtp->dispatch[i]->cb(lmtp, &lmtp->io, &req, lmtp->dispatch[i]->ctx);
+ if (req.msg != NULL)
+ free(req.msg);
+ req.verb = "";
+ req.msg = NULL;
+
if (rc != LMTP_OK)
break;
}
|
|