Skip to content

Commit f0413a6

Browse files
authored
test_client: Don't segfault if file cannot be opened (#455)
1 parent acea9b0 commit f0413a6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_client.c

+8
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,10 @@ save_session_cb(const char * data, size_t data_len, void *user_data)
780780
printf("save_session_cb use server domain as the key. h3[%d]\n", user_conn->h3);
781781

782782
FILE * fp = fopen("test_session", "wb");
783+
if (fp == NULL) {
784+
printf("'test_session' open error");
785+
return;
786+
}
783787
int write_size = fwrite(data, 1, data_len, fp);
784788
if (data_len != write_size) {
785789
printf("save _session_cb error\n");
@@ -798,6 +802,10 @@ save_tp_cb(const char * data, size_t data_len, void * user_data)
798802
printf("save_tp_cb use server domain as the key. h3[%d]\n", user_conn->h3);
799803

800804
FILE * fp = fopen("tp_localhost", "wb");
805+
if (fp == NULL) {
806+
printf("'tp_localhost' open error");
807+
return;
808+
}
801809
int write_size = fwrite(data, 1, data_len, fp);
802810
if (data_len != write_size) {
803811
printf("save _tp_cb error\n");

0 commit comments

Comments
 (0)