@@ -3532,6 +3532,7 @@ bool _php_imap_mail(zend_string *to, zend_string *subject, zend_string *message,
3532
3532
3533
3533
ZEND_ASSERT (to && ZSTR_LEN (to ) != 0 );
3534
3534
ZEND_ASSERT (subject && ZSTR_LEN (subject ) != 0 );
3535
+ ZEND_ASSERT (message );
3535
3536
3536
3537
#ifdef PHP_WIN32
3537
3538
char * tempMailTo ;
@@ -3661,14 +3662,23 @@ bool _php_imap_mail(zend_string *to, zend_string *subject, zend_string *message,
3661
3662
}
3662
3663
sendmail = popen (INI_STR ("sendmail_path" ), "w" );
3663
3664
if (sendmail ) {
3664
- if (ZSTR_LEN (rpath ) != 0 ) fprintf (sendmail , "From: %s\n" , ZSTR_VAL (rpath ));
3665
+ if (rpath && ZSTR_LEN (rpath ) != 0 ) {
3666
+ fprintf (sendmail , "From: %s\n" , ZSTR_VAL (rpath ));
3667
+ }
3668
+ /* to cannot be a null pointer, asserted earlier on */
3665
3669
fprintf (sendmail , "To: %s\n" , ZSTR_VAL (to ));
3666
- if (ZSTR_LEN (cc ) != 0 ) fprintf (sendmail , "Cc: %s\n" , ZSTR_VAL (cc ));
3667
- if (ZSTR_LEN (bcc ) != 0 ) fprintf (sendmail , "Bcc: %s\n" , ZSTR_VAL (bcc ));
3670
+ if (cc && ZSTR_LEN (cc ) != 0 ) {
3671
+ fprintf (sendmail , "Cc: %s\n" , ZSTR_VAL (cc ));
3672
+ }
3673
+ if (bcc && ZSTR_LEN (bcc ) != 0 ) {
3674
+ fprintf (sendmail , "Bcc: %s\n" , ZSTR_VAL (bcc ));
3675
+ }
3676
+ /* subject cannot be a null pointer, asserted earlier on */
3668
3677
fprintf (sendmail , "Subject: %s\n" , ZSTR_VAL (subject ));
3669
- if (headers != NULL ) {
3678
+ if (headers && ZSTR_LEN ( headers ) != 0 ) {
3670
3679
fprintf (sendmail , "%s\n" , ZSTR_VAL (headers ));
3671
3680
}
3681
+ /* message cannot be a null pointer, asserted earlier on */
3672
3682
fprintf (sendmail , "\n%s\n" , ZSTR_VAL (message ));
3673
3683
ret = pclose (sendmail );
3674
3684
0 commit comments