Fix memory leak in Imagick::colorThresholdImage()#782
Open
ndossche wants to merge 2 commits into
Open
Conversation
When `stop_color_wand` is invalid but `start_color_wand` was valid, this
will leak memory:
```
Indirect leak of 56 byte(s) in 1 object(s) allocated from:
#0 0x7f1f8c72c161 in malloc (/usr/lib/libasan.so.8+0x12c161) (BuildId: ee5fbab73143ab257a66a33afe0f038a4af7a74e)
Imagick#1 0x7b1f857441ed in AcquireCriticalMemory (/usr/lib/libMagickCore-7.Q16HDRI.so.10+0x1441ed) (BuildId: 37b980917ab6f85c1f92a6f03b43ca060849d66a)
Imagick#2 0x7b1f8570be36 in AcquireExceptionInfo (/usr/lib/libMagickCore-7.Q16HDRI.so.10+0x10be36) (BuildId: 37b980917ab6f85c1f92a6f03b43ca060849d66a)
Imagick#3 0x7b1f8819e024 in NewPixelWand (/usr/lib/libMagickWand-7.Q16HDRI.so.10+0x116024) (BuildId: c2b7b6550e6b44c7df1bc48cfa004cb88fe60627)
Imagick#4 0x7f1f889cbee6 in php_imagick_zval_to_pixelwand /run/media/niels/MoreData/imagick/imagick_helpers.c:787
Imagick#5 0x7f1f889bad88 in zim_Imagick_colorThresholdImage /run/media/niels/MoreData/imagick/imagick_class.c:13490
Imagick#6 0x563184fcea2e in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER /run/media/niels/MoreData/php-8.4/Zend/zend_vm_execute.h:1907
Imagick#7 0x56318512daed in execute_ex /run/media/niels/MoreData/php-8.4/Zend/zend_vm_execute.h:58947
Imagick#8 0x563185141866 in zend_execute /run/media/niels/MoreData/php-8.4/Zend/zend_vm_execute.h:64334
Imagick#9 0x5631852a6ef8 in zend_execute_script /run/media/niels/MoreData/php-8.4/Zend/zend.c:1934
Imagick#10 0x563184cf0fdb in php_execute_script_ex /run/media/niels/MoreData/php-8.4/main/main.c:2577
Imagick#11 0x563184cf148f in php_execute_script /run/media/niels/MoreData/php-8.4/main/main.c:2617
Imagick#12 0x5631852ac7e1 in do_cli /run/media/niels/MoreData/php-8.4/sapi/cli/php_cli.c:935
Imagick#13 0x5631852ae792 in main /run/media/niels/MoreData/php-8.4/sapi/cli/php_cli.c:1322
Imagick#14 0x7f1f8b827740 (/usr/lib/libc.so.6+0x27740) (BuildId: 020d6f7c33b2413f4fe10814c4729dce1387f049)
Imagick#15 0x7f1f8b827878 in __libc_start_main (/usr/lib/libc.so.6+0x27878) (BuildId: 020d6f7c33b2413f4fe10814c4729dce1387f049)
Imagick#16 0x563184205974 in _start (/usr/local/bin/php+0x605974) (BuildId: 69a1283cc37add59b1680b36e9f3ae4f04a82277)
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
stop_color_wandis invalid butstart_color_wandwas valid, this will leak memory:Note: this was found by a hybrid static-dynamic analyzer I'm developing.