Commit 354bcc9
committed
PHPC-1598: Fix get_gc handlers for classes with get_properties
The ReadConcern, ReadPreference, WriteConcern, and BSON classes have no properties beyond pointers to libmongoc/libbson structs; however, all of these classes use get_properties to report fields for var_export (PHPC-850, PHPC-460).
The standard get_gc handler defers to get_properties to collect other zvals for GC inspection. This is problematic for the aforementioned get_properties handlers, since a HashTable of zvals intended for debugging will be returned and those properties will already be freed by our free_object handler (via FREE_HASHTABLE).
Having each class define its own get_gc handler is the first step to fixing this issue. The BSON classes already defined their own get_gc handlers, but erroneously returned the internally cached properties directly.
The second step to fixing this issue is ensuring that get_gc delegates to zend_std_get_properties, as is done in various PHP core extensions. Doing so ensures that we do not leak other zvals that may be assigned as public properties by the application (covered by the second regression test), since zend_std_get_properties will return those for GC inspection.1 parent 7055b2e commit 354bcc9
File tree
19 files changed
+370
-97
lines changed- src/BSON
- tests
- bson
- readConcern
- readPreference
- writeConcern
19 files changed
+370
-97
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3486 | 3486 | | |
3487 | 3487 | | |
3488 | 3488 | | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
3489 | 3496 | | |
3490 | 3497 | | |
3491 | 3498 | | |
| |||
3501 | 3508 | | |
3502 | 3509 | | |
3503 | 3510 | | |
| 3511 | + | |
| 3512 | + | |
3504 | 3513 | | |
3505 | | - | |
3506 | | - | |
3507 | | - | |
3508 | | - | |
3509 | | - | |
3510 | | - | |
3511 | | - | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
3512 | 3517 | | |
3513 | 3518 | | |
3514 | 3519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | 352 | | |
361 | 353 | | |
362 | 354 | | |
| |||
413 | 405 | | |
414 | 406 | | |
415 | 407 | | |
416 | | - | |
417 | 408 | | |
418 | 409 | | |
419 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | 265 | | |
274 | 266 | | |
275 | 267 | | |
| |||
324 | 316 | | |
325 | 317 | | |
326 | 318 | | |
327 | | - | |
328 | 319 | | |
329 | 320 | | |
330 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | 279 | | |
288 | 280 | | |
289 | 281 | | |
| |||
339 | 331 | | |
340 | 332 | | |
341 | 333 | | |
342 | | - | |
343 | 334 | | |
344 | 335 | | |
345 | 336 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | 245 | | |
254 | 246 | | |
255 | 247 | | |
| |||
302 | 294 | | |
303 | 295 | | |
304 | 296 | | |
305 | | - | |
306 | 297 | | |
307 | 298 | | |
308 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | 383 | | |
392 | 384 | | |
393 | 385 | | |
| |||
462 | 454 | | |
463 | 455 | | |
464 | 456 | | |
465 | | - | |
466 | 457 | | |
467 | 458 | | |
468 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | 329 | | |
338 | 330 | | |
339 | 331 | | |
| |||
387 | 379 | | |
388 | 380 | | |
389 | 381 | | |
390 | | - | |
391 | 382 | | |
392 | 383 | | |
393 | 384 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | 363 | | |
372 | 364 | | |
373 | 365 | | |
| |||
424 | 416 | | |
425 | 417 | | |
426 | 418 | | |
427 | | - | |
428 | 419 | | |
429 | 420 | | |
430 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | 236 | | |
245 | 237 | | |
246 | 238 | | |
| |||
293 | 285 | | |
294 | 286 | | |
295 | 287 | | |
296 | | - | |
297 | 288 | | |
298 | 289 | | |
299 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | 398 | | |
407 | 399 | | |
408 | 400 | | |
| |||
466 | 458 | | |
467 | 459 | | |
468 | 460 | | |
469 | | - | |
470 | 461 | | |
471 | 462 | | |
472 | 463 | | |
| |||
0 commit comments