diff --git a/coreapi/chat.c b/coreapi/chat.c index 1f8df2a14..ac2e6e291 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -297,7 +297,7 @@ bool_t linphone_chat_room_lime_available(LinphoneChatRoom *cr) { associatedKeys.peerKeys = NULL; res = (lime_getCachedSndKeysByURI(cacheXml, &associatedKeys) == 0 && associatedKeys.associatedZIDNumber != 0); - lime_freeKeys(associatedKeys); + lime_freeKeys(&associatedKeys); xmlFreeDoc(cacheXml); return res; } diff --git a/coreapi/lime.c b/coreapi/lime.c index 89a3b11c0..e7b297dfb 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -459,21 +459,21 @@ static int lime_deriveKey(limeKey_t *key) { return 0; } -void lime_freeKeys(limeURIKeys_t associatedKeys) { +void lime_freeKeys(limeURIKeys_t *associatedKeys) { int i; /* free all associated keys */ - for (i=0; i< associatedKeys.associatedZIDNumber; i++) { - if (associatedKeys.peerKeys[i] != NULL) { - free(associatedKeys.peerKeys[i]); - associatedKeys.peerKeys[i] = NULL; + for (i=0; i< associatedKeys->associatedZIDNumber; i++) { + if (associatedKeys->peerKeys[i] != NULL) { + free(associatedKeys->peerKeys[i]); + associatedKeys->peerKeys[i] = NULL; } } - free(associatedKeys.peerKeys); + free(associatedKeys->peerKeys); /* free sipURI string */ - free(associatedKeys.peerURI); + free(associatedKeys->peerURI); } int lime_encryptMessage(limeKey_t *key, uint8_t *plainMessage, uint32_t messageLength, uint8_t selfZID[12], uint8_t *encryptedMessage) { @@ -594,12 +594,12 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t associatedKeys.peerKeys = NULL; if (lime_getCachedSndKeysByURI(cacheBuffer, &associatedKeys) != 0) { - lime_freeKeys(associatedKeys); + lime_freeKeys(&associatedKeys); return LIME_UNABLE_TO_ENCRYPT_MESSAGE; } if (associatedKeys.associatedZIDNumber == 0) { - lime_freeKeys(associatedKeys); + lime_freeKeys(&associatedKeys); return LIME_NO_VALID_KEY_FOUND_FOR_PEER; } @@ -667,7 +667,7 @@ int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t xmlDocDumpFormatMemoryEnc(xmlOutputMessage, output, &xmlStringLength, "UTF-8", 0); xmlFreeDoc(xmlOutputMessage); - lime_freeKeys(associatedKeys); + lime_freeKeys(&associatedKeys); return 0; } @@ -817,7 +817,7 @@ int lime_decryptFile(void **cryptoContext, unsigned char *key, size_t length, ch int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t **output) { return LIME_NOT_ENABLED;} int lime_createMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_t *peerURI, uint8_t **output) { return LIME_NOT_ENABLED;} int lime_encryptFile(void **cryptoContext, unsigned char *key, size_t length, char *plain, char *cipher) {return LIME_NOT_ENABLED;} -void lime_freeKeys(limeURIKeys_t associatedKeys){ +void lime_freeKeys(limeURIKeys_t *associatedKeys){ } int lime_getCachedSndKeysByURI(xmlDocPtr cacheBuffer, limeURIKeys_t *associatedKeys){ return LIME_NOT_ENABLED; diff --git a/coreapi/lime.h b/coreapi/lime.h index a581a2a95..a77309b0b 100644 --- a/coreapi/lime.h +++ b/coreapi/lime.h @@ -98,11 +98,12 @@ LINPHONE_PUBLIC int lime_setCachedKey(xmlDocPtr cacheBuffer, limeKey_t *associat /** * @brief Free all allocated data in the associated keys structure * Note, this will also free the peerURI string which then must have been allocated + * This does not free the memory area pointed by associatedKeys. * * @param[in,out] associatedKeys The structure to be cleaned * */ -LINPHONE_PUBLIC void lime_freeKeys(limeURIKeys_t associatedKeys); +LINPHONE_PUBLIC void lime_freeKeys(limeURIKeys_t *associatedKeys); /** * @brief encrypt a message with the given key diff --git a/tester/message_tester.c b/tester/message_tester.c index aa228b3a1..26c615e7c 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1010,7 +1010,7 @@ static void lime_unit(void) { BC_ASSERT_EQUAL(retval, 0, int, "%d"); /* free memory */ - lime_freeKeys(associatedKeys); + lime_freeKeys(&associatedKeys); /* write the file */ /* dump the xml document into a string */