From 87f185d1af455844d258619d0cb71d035d125112 Mon Sep 17 00:00:00 2001 From: shipixian Date: Wed, 29 Mar 2023 11:30:09 +0800 Subject: [PATCH] fix free problem Signed-off-by: shipixian --- src/backend/storage/buffer/bufmgr.c | 2 +- src/backend/storage/file/fd.c | 2 +- src/backend/storage/smgr/md.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index b635554..0ffb108 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -1231,7 +1231,7 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum, free(pageXlogPtr); pageXlogPtr = NULL; } else if (tWalRecord.count != 0) { - free_dataRead(tWalRecord.buf,1,1); + free_dataRead(tWalRecord.buf,tWalRecord.count,tWalRecord.cap); FreeLsnNode(head); } else { if (walRecord.buf != NULL) { diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index edc23e4..4b28497 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -2437,7 +2437,7 @@ MasterFileRead(char *buffer,uint32_t dbid, uint32_t relid, uint32_t forkno, uint if (bufrd.count > 0) { memcpy(buffer,bufrd.buf,bufrd.count); - free_dataRead(bufrd.buf,1,1); + free_dataRead(bufrd.buf,bufrd.count, bufrd.cap); } return bufrd.count; diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 2faefd1..19eabc2 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -772,7 +772,7 @@ he3db_mdread_pagexlog(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknu nbytes = bufrd.count; *buffer = (uint8_t *)malloc(bufrd.count); memcpy(*buffer, bufrd.buf,bufrd.count); - free_dataRead(bufrd.buf, 1,1); + free_dataRead(bufrd.buf, bufrd.count, bufrd.cap); if (push_standby) { Assert(bufrd.count == BLCKSZ); @@ -789,7 +789,7 @@ he3db_mdread_pagexlog(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknu nbytes += result.count; *buffer = (uint8_t *)realloc(*buffer, BLCKSZ + result.count); strcat(*buffer,result.buf); - free_dataRead(result.buf, 1,1); + free_dataRead(result.buf, result.count, result.cap); } //TODO free result FreeLsnNode(head); @@ -845,7 +845,7 @@ he3db_mdread_pagexlog(SMgrRelation reln, ForkNumber forknum, BlockNumber blocknu buf = (uint8_t *)realloc(buf, BLCKSZ + result.count); strcat(buf,result.buf); //TODO free result - free_dataRead(result.buf, 1,1); + free_dataRead(result.buf, result.count, result.cap); } *buffer = buf; FreeLsnNode(head);