Skip to content

stringFromValue is leaking memory #194

@cunev

Description

@cunev
inline const char * stringFromValue(const Napi::CallbackInfo& info, int index) {
  std::string val = info[index].As<Napi::String>().Utf8Value();
  const std::string::size_type size = val.size();
  char *buffer = new char[size + 1];   //we need extra char for NUL
  memcpy(buffer, val.c_str(), size + 1);
  return buffer;
}

Caused by this function, where it clearly allocates memory on char *buffer = new char[size + 1];.
I noticed this when my game's memory was growing and I debugged it down to DrawTextEx call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions