acl-parser.y, handleacl.c, librfc822/test.c, rfcparse.c: free() can handle NULL pointers
This commit is contained in:
parent
bf894937ad
commit
b7fdc3911f
12
acl-parser.y
12
acl-parser.y
@ -105,32 +105,28 @@ action: TOK_PASS { $$ = ACL_PASS; }
|
|||||||
| TOK_REJECT { $$ = ACL_REJECT; }
|
| TOK_REJECT { $$ = ACL_REJECT; }
|
||||||
| TOK_REJECTWITH TOK_STRING {
|
| TOK_REJECTWITH TOK_STRING {
|
||||||
$$ = ACL_REJECTWITH;
|
$$ = ACL_REJECTWITH;
|
||||||
if (g_parameter != NULL)
|
free(g_parameter);
|
||||||
free(g_parameter);
|
|
||||||
g_parameter = strdup(acl_text);
|
g_parameter = strdup(acl_text);
|
||||||
if (g_parameter == NULL)
|
if (g_parameter == NULL)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
| TOK_REDIRECT TOK_STRING {
|
| TOK_REDIRECT TOK_STRING {
|
||||||
$$ = ACL_REDIRECT;
|
$$ = ACL_REDIRECT;
|
||||||
if (g_parameter != NULL)
|
free(g_parameter);
|
||||||
free(g_parameter);
|
|
||||||
g_parameter = strdup(acl_text);
|
g_parameter = strdup(acl_text);
|
||||||
if (g_parameter == NULL)
|
if (g_parameter == NULL)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
| TOK_FORWARD TOK_STRING {
|
| TOK_FORWARD TOK_STRING {
|
||||||
$$ = ACL_FORWARD;
|
$$ = ACL_FORWARD;
|
||||||
if (g_parameter != NULL)
|
free(g_parameter);
|
||||||
free(g_parameter);
|
|
||||||
g_parameter = strdup(acl_text);
|
g_parameter = strdup(acl_text);
|
||||||
if (g_parameter == NULL)
|
if (g_parameter == NULL)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
| TOK_FILTER TOK_STRING {
|
| TOK_FILTER TOK_STRING {
|
||||||
$$ = ACL_FILTER;
|
$$ = ACL_FILTER;
|
||||||
if (g_parameter != NULL)
|
free(g_parameter);
|
||||||
free(g_parameter);
|
|
||||||
g_parameter = strdup(acl_text);
|
g_parameter = strdup(acl_text);
|
||||||
if (g_parameter == NULL)
|
if (g_parameter == NULL)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|||||||
@ -151,8 +151,7 @@ handleACL(struct Mail * MailStruct, const char * listname, int operation, char *
|
|||||||
operation);
|
operation);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (parameter != NULL)
|
free(parameter);
|
||||||
free(parameter);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rfc822.h"
|
#include "rfc822.h"
|
||||||
#define safe_free(x) if (x) free(x)
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char ** argv)
|
main(int argc, char ** argv)
|
||||||
@ -52,9 +51,9 @@ main(int argc, char ** argv)
|
|||||||
rc = rfc822_parse_address(p, &address, &local, &host);
|
rc = rfc822_parse_address(p, &address, &local, &host);
|
||||||
if (rc == RFC822_OK) {
|
if (rc == RFC822_OK) {
|
||||||
printf("Address: '%s'\nLocal: '%s'\nHost: '%s'\n", address, local, host);
|
printf("Address: '%s'\nLocal: '%s'\nHost: '%s'\n", address, local, host);
|
||||||
safe_free(address);
|
free(address);
|
||||||
safe_free(local);
|
free(local);
|
||||||
safe_free(host);
|
free(host);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("Syntax error: %d\n", rc);
|
printf("Syntax error: %d\n", rc);
|
||||||
|
|||||||
@ -53,8 +53,7 @@ isRFC822Address(const char * buffer)
|
|||||||
|
|
||||||
rc = rfc822_parse_address(buffer, &address, NULL, NULL);
|
rc = rfc822_parse_address(buffer, &address, NULL, NULL);
|
||||||
if (rc == RFC822_OK) {
|
if (rc == RFC822_OK) {
|
||||||
if (address)
|
free(address);
|
||||||
free(address);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user