fix parise may cause segfault
This commit is contained in:
7
main.c
7
main.c
@@ -49,6 +49,7 @@ const char ENC_URL[] = "https://lbapi-rk.chaoxing.com/lb/parise/enc/get?subRoomI
|
||||
const char URL[] = "https://zhibo.chaoxing.com/apis/live/setLivePariseCountByEnc?subroomId=%s&enc=%s×tamp=%llu";
|
||||
const char SUBROOMID[] = "381236458034402305";
|
||||
const char SS[] = "381237373432790016";
|
||||
const char DNS[] = "8.8.8.8:53,114.114.114.114:53";
|
||||
static int flag = 1;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -103,6 +104,7 @@ CURLcode curl_get(const char *const url, struct memory *chunk)
|
||||
"Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0");
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||
curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, DNS);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_USE_SSL, true);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cb);
|
||||
@@ -190,7 +192,9 @@ void parise(void *arg)
|
||||
continue;
|
||||
|
||||
REGEN_URL_F(url, enc.enc, enc.timestamp);
|
||||
curl_get(url, &json_c);
|
||||
|
||||
if (curl_get(url, &json_c) != CURLE_OK)
|
||||
goto clean;
|
||||
|
||||
json = cJSON_Parse(json_c.response);
|
||||
result = cJSON_GetObjectItemCaseSensitive(json, "result");
|
||||
@@ -204,6 +208,7 @@ void parise(void *arg)
|
||||
fprintf(stderr, "\rT%d\t%s", idx, errorMsg->valuestring);
|
||||
fflush(stdout);
|
||||
|
||||
clean:
|
||||
free(enc.enc);
|
||||
free(json_c.response);
|
||||
cJSON_Delete(json);
|
||||
|
||||
Reference in New Issue
Block a user