代码好多地方存在内存泄漏,还有空指针导致程序崩溃的问题,主要现象就是连接wifi的时候卡住
目前改了一个
- /**
- * @brief HTTP解析请求数据
- *
- * @param https_request_data
- * @return char*
- */
- static char* https_get_data(const char* https_request_data)
- {
- char* request_data = https_request_data;
- static char* https_data;
- https_data = pvPortMalloc(1024*4);
- memset(https_data, 0, 1024*2);
- char* date = pvPortMalloc(64);
- char* request_value = strtok(request_data, "\n");
- for (size_t i = 0; i < 8; i++)
- {
- printf("%s\r\n", request_value);
- if (i==2) strcpy(date, request_value);
- request_value = strtok(NULL, "\n");
- }
- get_https_date(date);
- if (request_value != NULL) {
- strcpy(https_data, request_value);
- }
- vPortFree(date);
- return https_data;
- }
复制代码 |