Skip to content

Commit b9b9685

Browse files
committed
Constify hdr
1 parent 099c034 commit b9b9685

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ext/standard/mail.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ void php_mail_log_to_file(char *filename, char *message, size_t message_size) {
386386
}
387387

388388

389-
static int php_mail_detect_multiple_crlf(char *hdr) {
389+
static int php_mail_detect_multiple_crlf(const char *hdr) {
390390
/* This function detects multiple/malformed multiple newlines. */
391391

392392
if (!hdr || !strlen(hdr)) {
@@ -436,14 +436,15 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
436436
char *sendmail_path = INI_STR("sendmail_path");
437437
char *sendmail_cmd = NULL;
438438
char *mail_log = INI_STR("mail.log");
439-
char *hdr = (char *) headers;
439+
const char *hdr = headers;
440+
char *ahdr = NULL;
440441
#if PHP_SIGCHILD
441442
void (*sig_handler)() = NULL;
442443
#endif
443444

444445
#define MAIL_RET(val) \
445-
if (hdr != headers) { \
446-
efree(hdr); \
446+
if (ahdr != NULL) { \
447+
efree(ahdr); \
447448
} \
448449
return val; \
449450

@@ -486,10 +487,11 @@ PHPAPI int php_mail(const char *to, const char *subject, const char *message, co
486487
f = php_basename(tmp, strlen(tmp), NULL, 0);
487488

488489
if (headers != NULL && *headers) {
489-
spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers);
490+
spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s\r\n%s", php_getuid(), ZSTR_VAL(f), headers);
490491
} else {
491-
spprintf(&hdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f));
492+
spprintf(&ahdr, 0, "X-PHP-Originating-Script: " ZEND_LONG_FMT ":%s", php_getuid(), ZSTR_VAL(f));
492493
}
494+
hdr = ahdr;
493495
zend_string_release_ex(f, 0);
494496
}
495497

0 commit comments

Comments
 (0)