Skip to content

Fix leak in Array.prototype.indexOf() #427

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

Closed

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Jul 17, 2015

The leak occurs when fromIndex can't coerce to primitive value.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com

@dbatyai dbatyai added bug Undesired behaviour ecma builtins Related to ECMA built-in routines labels Jul 17, 2015
@dbatyai dbatyai added this to the ECMA builtins milestone Jul 17, 2015
@dbatyai dbatyai force-pushed the array_indexof_leak branch from b632674 to 3d3f467 Compare July 17, 2015 09:10
@@ -951,6 +950,9 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
/* 5. */
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_from_idx, arg2, ret_value);

ecma_number_t *num_p = ecma_alloc_number ();
*num_p = ecma_int32_to_number (-1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines could be moved to if block at line 991, and here we can define variable of ecma_number_t, not pointer.
In the case, call to ecma_dealloc_number at line 995 could be removed.

@ruben-ayrapetyan
Copy link
Contributor

Looks good to me

@zherczeg
Copy link
Member

+1 LGTM

…o primitive value.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai.u-szeged@partner.samsung.com
@dbatyai dbatyai force-pushed the array_indexof_leak branch from cc32d50 to 337c7cf Compare July 22, 2015 13:37
@egavrin
Copy link
Contributor

egavrin commented Jul 24, 2015

Merged 27161d3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour ecma builtins Related to ECMA built-in routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants