facebook / facebook/infer

False positive: RESOURCE_LEAK at SimplePing.m (Apple's sample)

Open
#788 1 comment 0 reactions 0 assignees View on GitHub
false-positive objective-c
Dominant language
OCaml
Stars
15.7k
Forks
2.1k
Avg merge
19h 36m
Merged PRs (30d)
13

Description

Language: Objective-C
Source: SimplePing.m from https://developer.apple.com/library/content/samplecode/SimplePing/Introduction/Intro.html
infer: v0.12.1

Error report:
SimplePing/Common/SimplePing.m:604: error: RESOURCE_LEAK
resource acquired by call to `socket()` at line 603, column 18 is not released after line 604, column 17
602. case AF_INET6: {
603. fd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6);
604. > if (fd < 0) {
605. err = errno;
606. }

SimplePing/Common/SimplePing.m:598: error: RESOURCE_LEAK
resource acquired by call to `socket()` at line 597, column 18 is not released after line 598, column 17
596. case AF_INET: {
597. fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
598. > if (fd < 0) {
599. err = errno;
600. }

But few lines below in code we can find this line:
`self.socket = (CFSocketRef) CFAutorelease( CFSocketCreateWithNative(NULL, fd, kCFSocketReadCallBack, SocketReadCallback, &context) );`. Therefore socket was managed correctly.

How i can suppress this kind of warnings?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.