Commit c027d84
committed
Fix memory leaks in record_out() and record_send().
record_out() leaks memory: it fails to free the strings returned by the
per-column output functions, and also is careless about detoasted values.
This results in a query-lifespan memory leakage when returning composite
values to the client, because printtup() runs the output functions in the
query-lifespan memory context. Fix it to handle these issues the same way
printtup() does. Also fix a similar leakage in record_send().
(At some point we might want to try to run output functions in
shorter-lived memory contexts, so that we don't need a zero-leakage policy
for them. But that would be a significantly more invasive patch, which
doesn't seem like material for back-patching.)
In passing, use appendStringInfoCharMacro instead of appendStringInfoChar
in the innermost data-copying loop of record_out, to try to shave a few
cycles from this function's runtime.
Per trouble report from Carlos Henrique Reimer. Back-patch to all
supported versions.1 parent 2faab1a commit c027d84
1 file changed
+40
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| 344 | + | |
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
| |||
363 | 365 | | |
364 | 366 | | |
365 | 367 | | |
366 | | - | |
367 | | - | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
| 370 | + | |
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
376 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
377 | 386 | | |
378 | 387 | | |
379 | 388 | | |
| |||
392 | 401 | | |
393 | 402 | | |
394 | 403 | | |
395 | | - | |
| 404 | + | |
396 | 405 | | |
397 | 406 | | |
398 | 407 | | |
399 | 408 | | |
400 | 409 | | |
401 | | - | |
402 | | - | |
| 410 | + | |
| 411 | + | |
403 | 412 | | |
404 | 413 | | |
405 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
406 | 421 | | |
407 | 422 | | |
408 | 423 | | |
| |||
690 | 705 | | |
691 | 706 | | |
692 | 707 | | |
| 708 | + | |
693 | 709 | | |
694 | 710 | | |
695 | 711 | | |
| |||
710 | 726 | | |
711 | 727 | | |
712 | 728 | | |
713 | | - | |
714 | | - | |
715 | 729 | | |
716 | 730 | | |
717 | | - | |
| 731 | + | |
718 | 732 | | |
719 | 733 | | |
720 | 734 | | |
721 | 735 | | |
722 | 736 | | |
723 | | - | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
724 | 747 | | |
725 | 748 | | |
726 | 749 | | |
727 | 750 | | |
728 | 751 | | |
| 752 | + | |
729 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
730 | 758 | | |
731 | 759 | | |
732 | 760 | | |
| |||
0 commit comments