Skip to content

Commit af09d36

Browse files
committed
feat: check CurrentMemoryContext is not Bump
Many operations require memory allocations and accordingly it's freeing. But Bump context do not have header and so can not perform some operations including 'pfree'. So we should check and deny any allocation sensetive operations - not only 'palloc' explicitly, but also any functions that may use memory allocations, i.e. various 'out' functions.
1 parent 474a9ae commit af09d36

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/variables.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,17 @@ function isValidMemoryContextTag(tag: string) {
10351035
case 'T_AllocSetContext':
10361036
case 'T_SlabContext': /* 10 */
10371037
case 'T_GenerationContext': /* 11 */
1038-
case 'T_BumpContext': /* 17 */
10391038
return true;
1039+
case 'T_BumpContext': /* 17 */
1040+
/*
1041+
* If we are going to perform memory allocations then we are
1042+
* going to free allocated memory accordingly.
1043+
* But Bump context does not allow pfree/repalloc/etc... operations.
1044+
*
1045+
* We can create our own memory context to perform allocations here,
1046+
* but it will be hard to maintain.
1047+
*/
1048+
return false;
10401049
}
10411050

10421051
/* This is T_Invalid or something else */
@@ -5870,6 +5879,8 @@ class TupleTableSlotAttributesVariable extends Variable {
58705879
}
58715880

58725881
async doGetChildren() {
5882+
await this.checkCanAlloc();
5883+
58735884
const nvalid = await this.slot.getMemberValueNumber('tts_nvalid');
58745885
if (nvalid == 0) {
58755886
return [];

0 commit comments

Comments
 (0)