!6328 解决部分内存问题

Merge pull request !6328 from Carl/heru
This commit is contained in:
opengauss_bot
2024-09-15 09:14:33 +00:00
committed by Gitee
4 changed files with 23 additions and 5 deletions

View File

@ -732,9 +732,10 @@ bool CheckIfEanbedSaveSlots()
securec_check_c(ret, "", "");
if ((strcmp(optvalue, "1") == 0) || (strcmp(optvalue, "true") == 0) || (strcmp(optvalue, "on") == 0)) {
pg_log(PG_PROGRESS, _("Enable saving confirmed_lsn in target %s\n"), config_file);
freefile(optlines);
return true;
}
}
freefile(optlines);
return false;
}

View File

@ -303,6 +303,11 @@ static void print_top_stack(int fd, uintptr_t sp)
{
output(fd, "====== Top of stack ======\nsp = 0x016%lx\n", sp);
if (sp == 0) {
output(fd, "Invalid stack pointer\n");
return;
}
uint64 *start = (uint64 *)sp;
uint64 *end = start + 64;

View File

@ -758,7 +758,6 @@ int gs_thread_create_ex(gs_thread_t* th, void* (*taskRoutine)(void*), int argc,
int error_code = 0;
bool needFree = false;
pArg = (ThreadArg*)argv;
if (argv == NULL) {
/*
* just special thread which not exit at gaussdb runtime, so the pArg no need to free. for example: signal
@ -778,6 +777,8 @@ int gs_thread_create_ex(gs_thread_t* th, void* (*taskRoutine)(void*), int argc,
*/
pArg->next = (struct ThreadArg*)INVALID_NEXT_ADDR;
needFree = true;
} else {
pArg = (ThreadArg*)argv;
}
pArg->m_taskRoutine = taskRoutine;

View File

@ -146,6 +146,7 @@ static CmkemErrCode create_file_and_write(const char *real_path, const unsigned
int fd = 0;
char head[KEY_FILE_HEADER_LEN] = {0};
errno_t rc = 0;
ssize_t written = 0;
fd = open(real_path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
if (fd == -1) {
@ -156,12 +157,22 @@ static CmkemErrCode create_file_and_write(const char *real_path, const unsigned
if (is_write_header) {
rc = sprintf_s(head, sizeof(head), "%lu", content_len);
securec_check_ss_c(rc, "", "");
write(fd, head, sizeof(head));
written = write(fd, head, sizeof(head));
if (written != sizeof(head)) {
cmkem_errmsg("failed to write header to file '%s'.\n", real_path);
(void)close(fd);
return CMKEM_WRITE_FILE_ERR;
}
}
write(fd, content, content_len);
close(fd);
written = write(fd, content, content_len);
if (written != content_len) {
cmkem_errmsg("failed to write content to file '%s'.\n", real_path);
(void)close(fd);
return CMKEM_WRITE_FILE_ERR;
}
(void)close(fd);
return CMKEM_SUCCEED;
}