fix JNI objects allocation and memory corruption

- we were allocating objects with a destructor in the command stream
  which is always invalid because there is no guarantee that when 
  the callback is called, the underlaying memory is still valid
  (and it wasn't).

- AutoBuffer move-ctor wasn't moving some of its state, which would
  lead to destroying the same ref several times.
This commit is contained in:
Pixelflinger
2020-05-06 16:51:19 -07:00
committed by Mathias Agopian
parent 920dc6b167
commit 786dbdc6e4
5 changed files with 15 additions and 11 deletions

View File

@@ -446,12 +446,11 @@ public:
static void invoke(void* buffer, size_t n, void* user) {
AutoBitmap* data = reinterpret_cast<AutoBitmap*>(user);
data->~AutoBitmap();
delete data;
}
static AutoBitmap* make(Engine* engine, JNIEnv* env, jobject bitmap) {
void* that = engine->streamAlloc(sizeof(AutoBitmap), alignof(AutoBitmap));
return new (that) AutoBitmap(env, bitmap);
return new AutoBitmap(env, bitmap);
}
private: