Skip to content

Potential double free at src/tools/wasm-opcodecnt.cc::ProgramMain #570

@viennadd

Description

@viennadd

Hi all,

Our code scanner has reported a double free at wasm-opcodecnt.cc#L221,

There are two delete[] data inside function ProgramMain, if read_file failed, it could occur some unexpected behaviors.
May be we can add a return statement after the first delete to avoid this?

  char* data;
  size_t size;
  Result result = read_file(s_infile, &data, &size);
  if (Failed(result)) {
    const char* input_name = s_infile ? s_infile : "stdin";
    ERROR("Unable to parse: %s", input_name);
    delete[] data;        //  <===
  }

  if (Succeeded(result)) {
   ....
  }
  delete[] data;         //  <====
  return result != Result::Ok;

SourceBrella Inc.
Alex

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions