Browse Source

no leaks in recursion 2

Carlos Aguilar 6 years ago
parent
commit
664a7000bc

+ 6 - 4
apps/simplepir/simplePIR.cpp

@@ -77,7 +77,7 @@ bool run(DBHandler *db, uint64_t chosen_element, PIRParameters params){
    * DO NOT try to use the same reply generator more than once, this causes issues
    * ******************************************************************************/
 
-#if 1
+#if 0
   // Generate 3 replies from 3 queries
   for (int i = 0 ; i < 3 ; i++){
 
@@ -210,6 +210,7 @@ int main(int argc, char * argv[]) {
   // nb_files=db.getNbStream();database_size = db.getDBSizeinbits();
   // maxFileBytesize = database_size/nb_files;
 
+#if 0
   // Simple test
   std::cout << "======================================================================" << std::endl;
   std::cout << "Test 1/7: database_size = 1ULL<<30; nb_files = 20;" << std::endl;
@@ -225,7 +226,6 @@ int main(int argc, char * argv[]) {
   params.crypto_params = "LWE:80:2048:120"; 
   tests_failed |= run(&db, chosen_element, params);
   
-#if 0
   // Test with aggregation
   // WARNING we must provide the representation of the database GIVEN recursion and aggregation
   // as here we have 100 elements and aggregate them in a unique group we have params.n[0]=1
@@ -239,7 +239,8 @@ int main(int argc, char * argv[]) {
   params.alpha = 100; params.d = 1; params.n[0] = 1; 
   params.crypto_params = "LWE:80:2048:120";
   tests_failed |= run(&db2, chosen_element, params);
-  
+#endif
+
   // Test with recursion 2
   std::cout << "======================================================================" << std::endl;
   std::cout << "Test 3/7: database_size = 1ULL<<25; nb_files = 100;" << std::endl;
@@ -252,6 +253,7 @@ int main(int argc, char * argv[]) {
   params.crypto_params = "LWE:80:2048:120";
   tests_failed |= run(&db3, chosen_element, params);
   
+#if 0
   // Test with recursion 2 and aggregation
   std::cout << "======================================================================" << std::endl;
   std::cout << "Test 4/7: database_size = 1ULL<<25; nb_files = 100;" << std::endl;
@@ -308,8 +310,8 @@ int main(int argc, char * argv[]) {
     params.crypto_params = "LWE:80:2048:120";
     tests_failed |= run(&db7, chosen_element, params);
   }
-
 #endif
+
   if (tests_failed) 
   {
     std::cout << "WARNING : at least one tests failed" << std::endl;

+ 9 - 1
pir/replyGenerator/PIRReplyGeneratorNFL_internal.cpp

@@ -449,7 +449,15 @@ void PIRReplyGeneratorNFL_internal::generateReply()
       cout << "PIRReplyGeneratorNFL_internal: reply_elt_nbr_OLD: " << old_reply_elt_nbr << endl;
     }
 #endif
-    // When i=> 2 clean old in_data.
+    if (i > 0)
+    { 
+      for (int j = 0 ; j < old_reply_elt_nbr ; j++)
+      {
+        free(in_data[j].p[0]);
+        free(in_data[j].p);
+      }
+      delete[] in_data;
+    }
     if (i < pirParam.d - 1) { 
       old_poly_nbr = currentMaxNbPolys;
       in_data = fromResulttoInData(inter_reply, reply_elt_nbr, i);