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_REJECTWITH TOK_STRING {
|
||||
$$ = ACL_REJECTWITH;
|
||||
if (g_parameter != NULL)
|
||||
free(g_parameter);
|
||||
free(g_parameter);
|
||||
g_parameter = strdup(acl_text);
|
||||
if (g_parameter == NULL)
|
||||
YYABORT;
|
||||
}
|
||||
| TOK_REDIRECT TOK_STRING {
|
||||
$$ = ACL_REDIRECT;
|
||||
if (g_parameter != NULL)
|
||||
free(g_parameter);
|
||||
free(g_parameter);
|
||||
g_parameter = strdup(acl_text);
|
||||
if (g_parameter == NULL)
|
||||
YYABORT;
|
||||
}
|
||||
| TOK_FORWARD TOK_STRING {
|
||||
$$ = ACL_FORWARD;
|
||||
if (g_parameter != NULL)
|
||||
free(g_parameter);
|
||||
free(g_parameter);
|
||||
g_parameter = strdup(acl_text);
|
||||
if (g_parameter == NULL)
|
||||
YYABORT;
|
||||
}
|
||||
| TOK_FILTER TOK_STRING {
|
||||
$$ = ACL_FILTER;
|
||||
if (g_parameter != NULL)
|
||||
free(g_parameter);
|
||||
free(g_parameter);
|
||||
g_parameter = strdup(acl_text);
|
||||
if (g_parameter == NULL)
|
||||
YYABORT;
|
||||
|
||||
@ -151,8 +151,7 @@ handleACL(struct Mail * MailStruct, const char * listname, int operation, char *
|
||||
operation);
|
||||
return -1;
|
||||
}
|
||||
if (parameter != NULL)
|
||||
free(parameter);
|
||||
free(parameter);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#endif
|
||||
|
||||
#include "rfc822.h"
|
||||
#define safe_free(x) if (x) free(x)
|
||||
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
@ -52,9 +51,9 @@ main(int argc, char ** argv)
|
||||
rc = rfc822_parse_address(p, &address, &local, &host);
|
||||
if (rc == RFC822_OK) {
|
||||
printf("Address: '%s'\nLocal: '%s'\nHost: '%s'\n", address, local, host);
|
||||
safe_free(address);
|
||||
safe_free(local);
|
||||
safe_free(host);
|
||||
free(address);
|
||||
free(local);
|
||||
free(host);
|
||||
}
|
||||
else
|
||||
printf("Syntax error: %d\n", rc);
|
||||
|
||||
@ -53,8 +53,7 @@ isRFC822Address(const char * buffer)
|
||||
|
||||
rc = rfc822_parse_address(buffer, &address, NULL, NULL);
|
||||
if (rc == RFC822_OK) {
|
||||
if (address)
|
||||
free(address);
|
||||
free(address);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user