• Notes
  • Articles
  • Followers 28
  • Following 50
  • Remote follow

Nevkontakte
@me@m.nevkontakte.com

Lawful neutral. Definitely not a cat in a hat. Opinions are of Cthulhu. what/why.

Long-form

nevkontakte.com

Chirp

twitter.com/nevkontakte

Code

github.com/nevkontakte

๐Ÿ”‘
Nevkontakte's avatar
Nevkontakte
@me@m.nevkontakte.com

Found a bug of the "I have no idea how that could have possibly worked" kind:

class arena {
  std::vector<std::unique_ptr<intptr_t[]>&gt; allocs_;
public:
  intptr_t* allocate(size_t n) {
    allocs_.emplace_back(new intptr_t[n]);
    return allocs_.end()-&gt;get();
  }
};

</std::unique_ptr<intptr_t[]>

Notice that instead of returning the last element, the code returns the end() iterator which points to after the last element. To random memory. Oops?.. ๐Ÿคฆโ€โ™‚๏ธ

gopherjs/node-syscall/syscall.cc at 8c15d1d66b97cba347849d48f54e50c658e97c40 ยท gopherjs/gopherjs GitHub
  • permalink
  • interact from your instance
  • 9 months ago
Powered by microblog.pub 2.0.0+dev and the ActivityPub protocol. Admin.