0002-allocate-the-correct-amount-of-memory-in-permanent-s.patch
application/octet-stream
Filename: 0002-allocate-the-correct-amount-of-memory-in-permanent-s.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0002
Subject: allocate the correct amount of memory in permanent storage
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc.c | 7 | 2 |
From 27fec1bbb076a11ac6139cb41456cd02ea25b02a Mon Sep 17 00:00:00 2001
From: Dave Cramer <davecramer@gmail.com>
Date: Tue, 26 Jul 2022 08:01:30 -0400
Subject: [PATCH 2/2] allocate the correct amount of memory in permanent
storage
---
src/backend/utils/misc/guc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index f8bdfcffe5..255e541d55 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -12952,10 +12952,14 @@ assign_format_binary(const char *newval, void *extra)
char *tmp = palloc(strlen(newval));
strcpy(tmp, newval);
+
+ /* Must save OID list in permanent storage. */
+ MemoryContext oldcxt = MemoryContextSwitchTo(TopMemoryContext);
+
// unlikely to have more than 16
int length = 16;
// +1 for the InvalidOid marker at the end
- Oid *tmpOids = palloc(length+1);
+ Oid *tmpOids = palloc(sizeof(Oid)*(length+1));
int i = 0;
char *token = strtok(tmp, ",");
@@ -12966,12 +12970,13 @@ assign_format_binary(const char *newval, void *extra)
if (i > length)
{
length += 16;
- tmpOids = repalloc(tmpOids, length+1);
+ tmpOids = repalloc(tmpOids, sizeof(Oid)*(length+1));
}
token = strtok(NULL, ",");
}
tmpOids[i] = InvalidOid;
binary_format_oids = tmpOids;
+ MemoryContextSwitchTo(oldcxt);
}
--
2.32.1 (Apple Git-133)