Skip to content

double execution with THROW_AND_RETURN_IF_OOB #41935

Closed
@powimod

Description

@powimod

Version

16.13.2

Platform

Microsoft Windows NT 10.0.19042.0 x64

Subsystem

No response

What steps will reproduce the bug?

In file node_buffer.cc, macro THROW_AND_RETURN_IF_OOB is called with a function as argument :

  THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[0], 0, &start));

This macro is replaced with this code :

  do {   \
    if ((ParseArrayIndex(env, args[0], 0, &start)).IsNothing()) return;  \
    if (!(ParseArrayIndex(env, args[0], 0, &start)).FromJust()) \
      return node::THROW_ERR_OUT_OF_RANGE(env, "Index out of range");       \
  } while (0) 

The ParseArrayIndex function will be called twice which will generate performance losses.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

Each macro call of THROW_AND_RETURN_IF_OOB macro should be checked.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.c++Issues and PRs that require attention from people who are familiar with C++.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions