Commit 8521da9
committed
libretro-common/queues: NULL-check allocations in generic_queue and task_queue
Several call sites in the queue implementation code allocated a
struct then immediately dereferenced it with no NULL check,
segfaulting on OOM:
* generic_queue_push (line 79): calloc then 5 field writes.
Also was missing the 'if (!queue) return' check that the
sibling generic_queue_shift has at line 134.
* generic_queue_shift (line 137): same as _push.
* generic_queue_iterator (line 217): malloc then 3 field writes.
* retro_task_regular_retrieve (task_queue.c line 312): malloc +
malloc back-to-back, then field writes on info. The inner
info->data malloc additionally fed into data->func which is
free to dereference it.
All four are void-returning or NULL-returning, so the appropriate
OOM behaviour is a silent skip / NULL return. length and the
first_item/last_item chain stay consistent on skip because we
return before incrementing anything.1 parent e3dc586 commit 8521da9
2 files changed
Lines changed: 45 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
80 | 94 | | |
81 | 95 | | |
82 | 96 | | |
| |||
134 | 148 | | |
135 | 149 | | |
136 | 150 | | |
137 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
138 | 159 | | |
139 | 160 | | |
140 | 161 | | |
| |||
214 | 235 | | |
215 | 236 | | |
216 | 237 | | |
217 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
218 | 245 | | |
219 | 246 | | |
220 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
315 | 326 | | |
316 | 327 | | |
317 | 328 | | |
| |||
0 commit comments