Commit de94601
src: add Malloc() size param + overflow detection
Adds an optional second parameter to `node::Malloc()` and
an optional third parameter to `node::Realloc()` giving the
size/number of items to be allocated, in the style of `calloc(3)`.
Use a proper overflow check using division;
the previous `CHECK_GE(n * size, n);` would not detect all cases
of overflow (e.g. `size == SIZE_MAX / 2 && n == 3`).
PR-URL: #8482
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ilkka Myller <[email protected]>1 parent f77cdf8 commit de94601
4 files changed
+25
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5592 | 5592 | | |
5593 | 5593 | | |
5594 | 5594 | | |
5595 | | - | |
5596 | 5595 | | |
5597 | 5596 | | |
5598 | | - | |
5599 | | - | |
| 5597 | + | |
| 5598 | + | |
5600 | 5599 | | |
5601 | 5600 | | |
5602 | 5601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
232 | 240 | | |
233 | 241 | | |
234 | 242 | | |
235 | 243 | | |
236 | 244 | | |
237 | 245 | | |
238 | 246 | | |
239 | | - | |
240 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
244 | | - | |
| 254 | + | |
| 255 | + | |
245 | 256 | | |
246 | 257 | | |
247 | 258 | | |
248 | | - | |
| 259 | + | |
| 260 | + | |
249 | 261 | | |
250 | | - | |
| 262 | + | |
251 | 263 | | |
252 | 264 | | |
253 | 265 | | |
254 | 266 | | |
255 | 267 | | |
256 | | - | |
| 268 | + | |
257 | 269 | | |
258 | 270 | | |
259 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 301 | + | |
305 | 302 | | |
306 | 303 | | |
307 | 304 | | |
| |||
0 commit comments