summaryrefslogtreecommitdiff
path: root/auto_tests/file_saving_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests/file_saving_test.c')
-rw-r--r--auto_tests/file_saving_test.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/auto_tests/file_saving_test.c b/auto_tests/file_saving_test.c
index 7faa6b20..cdcce95f 100644
--- a/auto_tests/file_saving_test.c
+++ b/auto_tests/file_saving_test.c
@@ -64,6 +64,7 @@ static void save_data_encrypted(void)
64static void load_data_decrypted(void) 64static void load_data_decrypted(void)
65{ 65{
66 FILE *f = fopen(savefile, "r"); 66 FILE *f = fopen(savefile, "r");
67 ck_assert(f != nullptr);
67 fseek(f, 0, SEEK_END); 68 fseek(f, 0, SEEK_END);
68 int64_t size = ftell(f); 69 int64_t size = ftell(f);
69 fseek(f, 0, SEEK_SET); 70 fseek(f, 0, SEEK_SET);
@@ -71,7 +72,9 @@ static void load_data_decrypted(void)
71 ck_assert_msg(0 <= size && size <= UINT_MAX, "file size out of range"); 72 ck_assert_msg(0 <= size && size <= UINT_MAX, "file size out of range");
72 73
73 uint8_t *cipher = (uint8_t *)malloc(size); 74 uint8_t *cipher = (uint8_t *)malloc(size);
75 ck_assert(cipher != nullptr);
74 uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH); 76 uint8_t *clear = (uint8_t *)malloc(size - TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
77 ck_assert(clear != nullptr);
75 size_t read_value = fread(cipher, sizeof(*cipher), size, f); 78 size_t read_value = fread(cipher, sizeof(*cipher), size, f);
76 printf("Read read_value = %u of %u\n", (unsigned)read_value, (unsigned)size); 79 printf("Read read_value = %u of %u\n", (unsigned)read_value, (unsigned)size);
77 80
@@ -81,6 +84,7 @@ static void load_data_decrypted(void)
81 "Could not decrypt, error code %d.", derr); 84 "Could not decrypt, error code %d.", derr);
82 85
83 struct Tox_Options *options = tox_options_new(nullptr); 86 struct Tox_Options *options = tox_options_new(nullptr);
87 ck_assert(options != nullptr);
84 88
85 tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE); 89 tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
86 90
@@ -101,10 +105,10 @@ static void load_data_decrypted(void)
101 ck_assert_msg(strcmp((const char *)readname, name) == 0, 105 ck_assert_msg(strcmp((const char *)readname, name) == 0,
102 "name returned by tox_self_get_name does not match expected result"); 106 "name returned by tox_self_get_name does not match expected result");
103 107
104 free(cipher); 108 tox_kill(t);
105 free(clear); 109 free(clear);
110 free(cipher);
106 fclose(f); 111 fclose(f);
107 tox_kill(t);
108} 112}
109 113
110int main(void) 114int main(void)