fuwaneko / node-protobuf

Google Protocol Buffers wrapper for Node.js [UNMAINTAINED]
181 stars 42 forks source link

Fix potential segfault #89

Closed webmakersteve closed 7 years ago

webmakersteve commented 7 years ago

There is a potential collision with the DynamicMessageFactory since it is statically scoped. If a new object is created with a different proto that has the same name as another, the factory strips it from the cache (as far as I can tell). However, descriptors generated from it still live within a pool, which tries to clean up, but now has invalid pointers.

By making the factory locally scoped, other encoders cannot affect this, which seems to stop the segfaults.

Additionally, had to make it so it was stack allocated rather than heap allocated, which required me to change the constructor slightly.

webmakersteve commented 7 years ago

Hopefully fixes #88

fuwaneko commented 7 years ago

Looks good, thanks for the investigation and PR.