Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP重定向访问时代码BUG导致释放内存被访问异常奔溃 #13

Open
Freelifeww opened this issue Feb 6, 2023 · 0 comments

Comments

@Freelifeww
Copy link

Freelifeww commented Feb 6, 2023

问题点,http_interceptor.c,266行:
参数1:interceptor->connect_params,重定向为新的URL数据
参数2:http_get_connect_params_url(interceptor->connect_params,重定向为新的URL数据同一个地址
http_url_parsing(interceptor->connect_params, http_get_connect_params_url(interceptor->connect_params));
解决办法:
新的的URL数据重新申请内存保存数据作为参数2传入完成URL的重新解析
const char *p_new_url = NULL;
int malloc_len = strlen(http_get_connect_params_url(interceptor->connect_params))+1;
p_new_url =(const char *)platform_memory_alloc(http_get_connect_params_url(malloc_len);
if(!p_new_url ) {
return;
}
memset(p_new_url,0,);
memcpy(p_new_url,http_get_connect_params_url(interceptor->connect_params),strlen(http_get_connect_params_url(interceptor->connect_params));
ret = http_url_parsing(interceptor->connect_params, p_new_url); //这里原来的地址重新申请的时候以及被释放了,所以这里需要拷贝一个新的地址处理
platform_memory_free(p_new_url);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant