From 06de47db2e497b60d420c2aa72107e3694f2ba8d Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Wed, 26 Nov 2014 13:40:53 +0100 Subject: [PATCH] Fix a special case in message history retrieval. This function is not yet completely tested, --- coreapi/message_storage.c | 2 +- tester/message_tester.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 55fc82685..2684ba0b5 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -371,7 +371,7 @@ MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, i if (startm<0) startm=0; - if (endm>0&&endm>=startm){ + if ((endm>0&&endm>=startm) || (startm == 0 && endm == 0) ){ buf2=ms_strdup_printf("%s LIMIT %i ",buf,endm+1-startm); ms_free(buf); buf = buf2; diff --git a/tester/message_tester.c b/tester/message_tester.c index 9d207d034..ab7a83077 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1045,6 +1045,10 @@ static void history_messages_count() { CU_ASSERT_EQUAL(ms_list_size(messages), 10); ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + messages=linphone_chat_room_get_history(chatroom,1); + CU_ASSERT_EQUAL(ms_list_size(messages), 1); + ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + messages=linphone_chat_room_get_history(chatroom,0); CU_ASSERT_EQUAL(linphone_chat_room_get_history_size(chatroom), 1270); CU_ASSERT_EQUAL(ms_list_size(messages), 1270);