ensure reset of prepared statement
authorKrista Bennett <krista@pep-project.org>
Mon, 19 Feb 2018 09:31:39 +0100
changeset 25175df0ed0fb25f
parent 2516 6e706549d666
child 2518 3284b121d10a
ensure reset of prepared statement
src/pEpEngine.c
     1.1 --- a/src/pEpEngine.c	Mon Feb 19 09:08:03 2018 +0100
     1.2 +++ b/src/pEpEngine.c	Mon Feb 19 09:31:39 2018 +0100
     1.3 @@ -1918,8 +1918,10 @@
     1.4                  (const char *) sqlite3_column_text(session->get_identity, 1)
     1.5                  );
     1.6          assert(_identity);
     1.7 -        if (_identity == NULL)
     1.8 +        if (_identity == NULL) {
     1.9 +            sqlite3_reset(session->get_identity);
    1.10              return PEP_OUT_OF_MEMORY;
    1.11 +        }
    1.12  
    1.13          _identity->comm_type = (PEP_comm_type)
    1.14              sqlite3_column_int(session->get_identity, 2);
    1.15 @@ -1941,6 +1943,7 @@
    1.16          *identity = _identity;
    1.17          break;
    1.18      default:
    1.19 +        sqlite3_reset(session->get_identity);
    1.20          status = PEP_CANNOT_FIND_IDENTITY;
    1.21          *identity = NULL;
    1.22      }
    1.23 @@ -1983,8 +1986,10 @@
    1.24                  (const char *) sqlite3_column_text(session->get_identity_without_trust_check, 1)
    1.25                  );
    1.26          assert(_identity);
    1.27 -        if (_identity == NULL)
    1.28 +        if (_identity == NULL) {
    1.29 +            sqlite3_reset(session->get_identity_without_trust_check);
    1.30              return PEP_OUT_OF_MEMORY;
    1.31 +        }
    1.32  
    1.33          _identity->comm_type = PEP_ct_unknown;
    1.34          const char* const _lang = (const char *)
    1.35 @@ -2046,8 +2051,10 @@
    1.36                  (const char *) sqlite3_column_text(session->get_identities_by_address, 2)
    1.37                  );
    1.38          assert(ident);
    1.39 -        if (ident == NULL)
    1.40 +        if (ident == NULL) {
    1.41 +            sqlite3_reset(session->get_identities_by_address);
    1.42              return PEP_OUT_OF_MEMORY;
    1.43 +        }
    1.44  
    1.45          ident->comm_type = PEP_ct_unknown;
    1.46          
    1.47 @@ -2093,6 +2100,8 @@
    1.48      
    1.49      *exists = false;
    1.50      
    1.51 +    PEP_STATUS status = PEP_STATUS_OK;
    1.52 +    
    1.53      sqlite3_reset(session->exists_identity_entry);
    1.54      sqlite3_bind_text(session->exists_identity_entry, 1, identity->address, -1,
    1.55                        SQLITE_STATIC);
    1.56 @@ -2106,10 +2115,11 @@
    1.57              *exists = (sqlite3_column_int(session->exists_identity_entry, 0) != 0);
    1.58              break;
    1.59          }
    1.60 -        default:
    1.61 -            return PEP_UNKNOWN_ERROR;
    1.62 +        default: 
    1.63 +            status = PEP_UNKNOWN_ERROR;
    1.64      }
    1.65  
    1.66 +    sqlite3_reset(session->exists_identity_entry);
    1.67      return PEP_STATUS_OK;
    1.68  }
    1.69  
    1.70 @@ -2124,6 +2134,8 @@
    1.71      
    1.72      *exists = false;
    1.73      
    1.74 +    PEP_STATUS status = PEP_STATUS_OK;
    1.75 +    
    1.76      sqlite3_reset(session->exists_trust_entry);
    1.77      sqlite3_bind_text(session->exists_trust_entry, 1, identity->user_id, -1,
    1.78                        SQLITE_STATIC);
    1.79 @@ -2138,9 +2150,10 @@
    1.80              break;
    1.81          }
    1.82          default:
    1.83 -            return PEP_UNKNOWN_ERROR;
    1.84 +            status = PEP_UNKNOWN_ERROR;
    1.85      }
    1.86 -
    1.87 +    
    1.88 +    sqlite3_reset(session->exists_trust_entry);
    1.89      return PEP_STATUS_OK;
    1.90  }
    1.91  
    1.92 @@ -2484,8 +2497,10 @@
    1.93                  break;
    1.94              }
    1.95              default:
    1.96 +                sqlite3_reset(session->exists_person);
    1.97                  return PEP_UNKNOWN_ERROR;
    1.98          }
    1.99 +        sqlite3_reset(session->exists_person);
   1.100      }
   1.101      else if (status == PEP_STATUS_OK) {
   1.102          *exists = true; // thank you, delete on cascade!
   1.103 @@ -2495,7 +2510,7 @@
   1.104      }
   1.105      else
   1.106          free(alias_default);
   1.107 -        
   1.108 +            
   1.109      return status;
   1.110  }
   1.111  
   1.112 @@ -2536,10 +2551,12 @@
   1.113              break;
   1.114          }
   1.115          default:
   1.116 +            sqlite3_reset(session->is_pep_user);
   1.117              free(alias_default);
   1.118              return PEP_CANNOT_FIND_PERSON;
   1.119      }
   1.120  
   1.121 +    sqlite3_reset(session->is_pep_user);
   1.122      return PEP_STATUS_OK;
   1.123  }
   1.124