Commit 5624d64
Fixing memory leaks observed in ASan (babelfish-for-postgresql#4690)
This commit fixes memory leaks observed when testing with ASan
1. In the function TdsSendRowDescription() , strdup() allocates memory using the system's malloc(), which is completely outside PostgreSQL's memory management. This means the string stored in relMetaDataInfo->partName[1] lives in malloc-heap, not in any PostgreSQL memory context.
By using pstrdup() , it allocates using palloc() inside the current memory context (MessageContext), so it's properly tracked and will be freed when that context is destroyed.
2. Similarly in the function rewrite_if_condition(), strdup uses malloc which is invisible to PostgreSQL's memory management while pstrdup allocates in the current memory context, which gets cleaned up automatically.
Task: BABEL-6422
Authored by : harshdu@amazon.com1 parent 5a8349b commit 5624d64
File tree
2 files changed
+8
-3
lines changed- contrib
- babelfishpg_tds/src/backend/tds
- babelfishpg_tsql/src
2 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1636 | 1636 | | |
1637 | 1637 | | |
1638 | 1638 | | |
1639 | | - | |
1640 | | - | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
1641 | 1646 | | |
1642 | 1647 | | |
1643 | 1648 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2999 | 2999 | | |
3000 | 3000 | | |
3001 | 3001 | | |
3002 | | - | |
| 3002 | + | |
3003 | 3003 | | |
3004 | 3004 | | |
3005 | 3005 | | |
| |||
0 commit comments