| Issue |
79329
|
| Summary |
Analyzer claims to have found potential memory leak, yet it clearly is not a leak
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
CodingMarkus
|
According to clang analyzer, the following code is a potential leak:
```
guard_C (certRef, SecCertificateCreateWithData(NULL, derData)) else return nil;
__auto_type const instance = [self initWithCertificate:certRef];
CFRelease(certRef);
return instance;
```
The `guard_C` macro expands as follows:
```
__auto_type const v_217 = (SecCertificateCreateWithData(NULL, derData));
__auto_type const n_217 = (typeof(* v_217) *_Nonnull)1;
__auto_type const certRef = (!v_217 ? n_217 : (typeof(* v_217) *_Nonnull)v_217);
if (certRef != n_217) { } else return nil;
```
This is clearly not a leak. `return nil` is only executed if `SecCertificateCreateWithData()` returned `NULL`.
More precisely, it is only executed if `certRef == n_217` and that is only the case if `v_217` is `NULL`.
If `v_217` is not `NULL`, `certRef == v_217`, so `certRef != n_217` is true, the else part is not executed, the code continues below the if and the result of `SecCertificateCreateWithData()` is released.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs