Skip to content

Fix mem leak in Source::newFromMemory() #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025

Conversation

kleisauke
Copy link
Member

Found while running the test suite with LeakSanitizer.

Details
=================================================================
==1212185==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2149584 byte(s) in 4 object(s) allocated from:
    #0 0x7fa8d34dab98 in malloc (/usr/lib64/llvm20/bin/../../../lib/clang/20/lib/x86_64-redhat-linux-gnu/libclang_rt.asan.so+0xdab98) (BuildId: aa6231e817f72469c44a6c6cee9f0694a87db7fb)
    #1 0x0000013099d3 in __zend_malloc /home/kleisauke/php-src/Zend/zend_alloc.c:3280:14
    #2 0x0000008a3233 in zim_FFI_new /home/kleisauke/php-src/ext/ffi/ffi.c:3915:8
    #3 0x00000151f0b1 in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER /home/kleisauke/php-src/Zend/zend_vm_execute.h:2025:4
    #4 0x0000014466dc in execute_ex /home/kleisauke/php-src/Zend/zend_vm_execute.h:58593:7
    #5 0x000001699b60 in zend_generator_resume /home/kleisauke/php-src/Zend/zend_generators.c:822:3
    #6 0x0000016a21aa in zend_generator_iterator_move_forward /home/kleisauke/php-src/Zend/zend_generators.c:1154:2
    #7 0x000001669501 in zend_fe_fetch_object_helper_SPEC /home/kleisauke/php-src/Zend/zend_vm_execute.h:2953:4
    #8 0x00000154aed7 in ZEND_FE_FETCH_R_SPEC_VAR_HANDLER /home/kleisauke/php-src/Zend/zend_vm_execute.h:23002:3
    #9 0x0000014466dc in execute_ex /home/kleisauke/php-src/Zend/zend_vm_execute.h:58593:7
    #10 0x000001446e5d in zend_execute /home/kleisauke/php-src/Zend/zend_vm_execute.h:64245:2
    #11 0x000001806207 in zend_execute_script /home/kleisauke/php-src/Zend/zend.c:1934:3
    #12 0x00000110846f in php_execute_script_ex /home/kleisauke/php-src/main/main.c:2575:13
    #13 0x000001108938 in php_execute_script /home/kleisauke/php-src/main/main.c:2615:9
    #14 0x00000180c030 in do_cli /home/kleisauke/php-src/sapi/cli/php_cli.c:935:5
    #15 0x00000180a419 in main /home/kleisauke/php-src/sapi/cli/php_cli.c:1310:18
    #16 0x7fa8d2ea35f4 in __libc_start_call_main (/usr/lib64/../lib64/libc.so.6+0x35f4) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116)
    #17 0x7fa8d2ea36a7 in __libc_start_main@GLIBC_2.2.5 (/usr/lib64/../lib64/libc.so.6+0x36a7) (BuildId: 2b3c02fe7e4d3811767175b6f323692a10a4e116)
    #18 0x0000004047b4 in _start (/opt/php/bin/php+0x4047b4) (BuildId: 0e33124a4bd60661ceaa03f37bd3b29e06bdd02d)

SUMMARY: AddressSanitizer: 2149584 byte(s) leaked in 4 allocation(s).

@jcupitt
Copy link
Member

jcupitt commented May 29, 2025

Another dumb error killed, nice job!

@jcupitt jcupitt merged commit 04b551e into libvips:master May 29, 2025
6 checks passed
@kleisauke kleisauke deleted the fix-source-from-mem-leak branch May 29, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants