Skip to content
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

fix: Fix NDArray::prod memory leak when using a PHP array as argument #29

Merged
merged 1 commit into from
Jul 25, 2023

Conversation

henrique-borba
Copy link
Member

When calling nd::prod with a PHP function as below the temporary NDArray* nda is not freed automatically.

$a = nd::prod([[1, 2], [3, 4]]);

I added the code below to check and free the input before returning when only one argument is provided to the function

...
value = NDArray_Float_Prod(nda);
        CHECK_INPUT_AND_FREE(a, nda);  // Check if nda is temporary and free before return
        RETURN_DOUBLE(value);

@henrique-borba henrique-borba added the bug Something isn't working label Jul 25, 2023
@henrique-borba henrique-borba self-assigned this Jul 25, 2023
@henrique-borba henrique-borba added this to the 0.2.0 milestone Jul 25, 2023
@henrique-borba henrique-borba merged commit 894b00f into main Jul 25, 2023
2 checks passed
@henrique-borba henrique-borba deleted the fix/prod_memory_leak branch July 25, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant