We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
res_state res = malloc(sizeof(struct __res_state)); int result = res_ninit(res); // 内存泄露1, 使用leaks检测发现有内存泄露问题,是什么原因?
NSMutableArray *servers = [[NSMutableArray alloc] init]; if (result == 0) { union res_9_sockaddr_union *addr_union = malloc(res->nscount * sizeof(union res_9_sockaddr_union)); // 内存泄露2 res_getservers(res, addr_union, res->nscount); for (int i = 0; i < res->nscount; i++) { if (addr_union[i].sin.sin_family == AF_INET) { char ip[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(addr_union[i].sin.sin_addr), ip, INET_ADDRSTRLEN); NSString *dnsIP = [NSString stringWithUTF8String:ip]; [servers addObject:dnsIP]; } else if (addr_union[i].sin6.sin6_family == AF_INET6) { char ip[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &(addr_union[i].sin6.sin6_addr), ip, INET6_ADDRSTRLEN); NSString *dnsIP = [NSString stringWithUTF8String:ip]; [servers addObject:dnsIP]; } } free(addr_union); // fix: 内存泄露2 } res_nclose(res); free(res);
The text was updated successfully, but these errors were encountered:
大佬,知道什么原因了么
Sorry, something went wrong.
No branches or pull requests
res_state res = malloc(sizeof(struct __res_state));
int result = res_ninit(res); // 内存泄露1, 使用leaks检测发现有内存泄露问题,是什么原因?
The text was updated successfully, but these errors were encountered: