Commit 140652f
Fix memory leak in XMLSERIALIZE(... INDENT).
xmltotext_with_options sometimes tries to replace the existing
root node of a libxml2 document. In that case xmlDocSetRootElement
will unlink and return the old root node; if we fail to free it,
it's leaked for the remainder of the session. The amount of memory
at stake is not large, a couple hundred bytes per occurrence, but
that could still become annoying in heavy usage.
Our only other xmlDocSetRootElement call is not at risk because
it's working on a just-created document, but let's modify that
code too to make it clear that it's dependent on that.
Author: Tom Lane <[email protected]>
Reviewed-by: Jim Jones <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 16
(cherry picked from commit 20bae0690322a00402b84119ddf2f959d24a211a)1 parent e29cff2 commit 140652f
1 file changed
+17
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
| 757 | + | |
757 | 758 | | |
758 | 759 | | |
759 | 760 | | |
760 | 761 | | |
761 | 762 | | |
762 | 763 | | |
763 | 764 | | |
764 | | - | |
765 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
766 | 773 | | |
767 | 774 | | |
768 | 775 | | |
| |||
1850 | 1857 | | |
1851 | 1858 | | |
1852 | 1859 | | |
| 1860 | + | |
1853 | 1861 | | |
1854 | 1862 | | |
1855 | 1863 | | |
| |||
1868 | 1876 | | |
1869 | 1877 | | |
1870 | 1878 | | |
1871 | | - | |
1872 | | - | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
1873 | 1886 | | |
1874 | 1887 | | |
1875 | 1888 | | |
| |||
0 commit comments