]> granicus.if.org Git - php/commitdiff
- #47940, leaks in imap_body()
authorPierre Joye <pajoye@php.net>
Thu, 23 Apr 2009 22:24:54 +0000 (22:24 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 23 Apr 2009 22:24:54 +0000 (22:24 +0000)
ext/imap/php_imap.c

index 1adb105ced19e16ab4e7a112d02c054822108221..7cc48e75d954d714f0fd90b536c6837c7823e667 100644 (file)
@@ -1560,6 +1560,8 @@ PHP_FUNCTION(imap_body)
        long msgno, flags = 0;
        pils *imap_le_struct; 
        int msgindex, argc = ZEND_NUM_ARGS();
+       char *body;
+       unsigned long body_len;
 
        if (zend_parse_parameters(argc TSRMLS_CC, "rl|l", &streamind, &msgno, &flags) == FAILURE) {
                return;
@@ -1586,7 +1588,13 @@ PHP_FUNCTION(imap_body)
                RETURN_FALSE;
        }
 
-       RETVAL_STRING(mail_fetchtext_full(imap_le_struct->imap_stream, msgno, NIL, (argc == 3 ? flags : NIL)), 1);
+       body = mail_fetchtext_full (imap_le_struct->imap_stream, msgno, &body_len, (argc == 3 ? flags : NIL));
+       if (body_len == 0) {
+               RETVAL_EMPTY_STRING();
+       } else {
+               RETVAL_STRINGL(body, body_len, 1);
+       }
+       free(body);
 }
 /* }}} */