Skip to content

readline memory leak #19686

@chongwick

Description

@chongwick

Description

The following code:

<?php
$v_55941 = '/tmp';
$v_55942 = 'readline.tmp';
$v_55943 = tempnam($v_55941,$v_55942,);
$v_55944 = 'line_buffer';
$v_55945 = readline_info($v_55944,);
$v_55947 = 'line_buffer';
$v_55948 = 'abcdef';
$v_55949 = readline_info($v_55947,$v_55948,);
#$v_55985 = '+5 days';
$v_55951 = readline_info($v_55985,);
$v_55953 = '123';
$v_55954 = readline_add_history($v_55953,);

Resulted in this output:

Warning: Undefined variable $v_55985 in 0c143fd4c4dc3b865f77.php.er on line 11

=================================================================
==1870153==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 7 byte(s) in 1 object(s) allocated from:
    #0 0x66cd54 in strdup (/home/w023dtc/nightly_php/php-src/sapi/cli/php+0x66cd54)
    #1 0x36c77c1 in zif_readline_info /home/w023dtc/nightly_php/php-src/ext/readline/readline.c:199:17
    #2 0x5fd774f in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:1410:2
    #3 0x5af34e3 in execute_ex /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:113454:12
    #4 0x5af5a6c in zend_execute /home/w023dtc/nightly_php/php-src/Zend/zend_vm_execute.h:119146:2
    #5 0x6874b19 in zend_execute_script /home/w023dtc/nightly_php/php-src/Zend/zend.c:1977:3
    #6 0x5059daa in php_execute_script_ex /home/w023dtc/nightly_php/php-src/main/main.c:2608:13
    #7 0x505aee8 in php_execute_script /home/w023dtc/nightly_php/php-src/main/main.c:2648:9
    #8 0x6889a2a in do_cli /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:952:5
    #9 0x6883e0f in main /home/w023dtc/nightly_php/php-src/sapi/cli/php_cli.c:1363:18
    #10 0x148355702d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

SUMMARY: AddressSanitizer: 7 byte(s) leaked in 1 allocation(s).

But I expected this output instead:

PHP Version

nightly

Operating System

ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions