[refNN] Fix possible memory leak (#1563)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Wed, 19 Sep 2018 06:44:54 +0000 (15:44 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 19 Sep 2018 06:44:54 +0000 (15:44 +0900)
In the current implementation, allocated event object will be leaked
if startCompute failed.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/ann/runtimes/ref/src/NeuralNetworks.cpp

index 186647b..38a7f2f 100644 (file)
@@ -316,13 +316,12 @@ int ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution *execution,
   // object.
   *event = nullptr;
 
-  int *e = new int;
   int n = r->startCompute();
   if (n != ANEURALNETWORKS_NO_ERROR)
   {
     return n;
   }
-  *event = reinterpret_cast<ANeuralNetworksEvent *>(e);
+  *event = reinterpret_cast<ANeuralNetworksEvent *>(new int);
   return ANEURALNETWORKS_NO_ERROR;
 }