| Ticket UUID: | 71b1e5e3318be7caac7c8960e82100f0fc749d86 | |||
| Title: | xgc.c: useless NULL check in XCreateGC() | |||
| Type: | Patch | Version: | 8.6.12 | |
| Submitter: | chrstphrchvz | Created on: | 2022-08-14 11:05:45 | |
| Subsystem: | 82. X11 Emulation | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Cosmetic | |
| Status: | Closed | Last Modified: | 2022-08-20 13:34:51 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2022-08-20 13:34:51 | |||
| Description: |
In `XCreateGC()`:
```
gp = (GC)ckalloc(sizeof(XGCValuesWithDash));
if (!gp) {
return NULL;
}
```
`ckalloc()` never returns `NULL` when given nonzero size (it will instead panic if allocation fails), and I don’t think there is any situation here where `ckalloc()` is given size of 0. So `return NULL` is unreachable. I suggest removing it, unless the intention was to use `attemptckalloc()`.
| |||
| User Comments: |
fvogel added on 2022-08-20 13:34:51:
Continuous integration (Github Actions) is happy, therefore now merged in core-8-6-branch and trunk. Thanks! fvogel added on 2022-08-19 20:06:44: I understand your point. XGCValuesWithDash is defined in xgc.c and has non-zero size. We don't check for NULL return values of ckalloc() in similar situations elsewhere in the code I think, for the reason you mention. I have committed your patch in [8656d3f4cd]. | |||