Skip to content

Commit eeaaead

Browse files
knizhniklubennikovaav
authored andcommitted
Add check for NULL for malloc in InternalIpcMemoryCreate (#173)
* Add check for NULL for malloc in InternalIpcMemoryCreate * apply pgindent
1 parent 5afaed3 commit eeaaead

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/backend/port/sysv_shmem.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,22 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
155155
}
156156
}
157157
#endif
158+
158159
/*
159-
* NEON: do not create shared memory segments for single user wal redo postgres.
160-
* Many spawned instances of wal redo may exhaust kernel.shmmni
160+
* NEON: do not create shared memory segments for single user wal redo
161+
* postgres. Many spawned instances of wal redo may exhaust kernel.shmmni
161162
*/
162163
if (am_wal_redo_postgres)
163-
return valloc(size);
164+
{
165+
void *ptr = malloc(size);
164166

167+
if (ptr == NULL)
168+
{
169+
ereport(FATAL,
170+
(errmsg("could not create shared memory segment with size %zu for WAL redo process", size)));
171+
}
172+
return ptr;
173+
}
165174
shmid = shmget(memKey, size, IPC_CREAT | IPC_EXCL | IPCProtection);
166175

167176
if (shmid < 0)

0 commit comments

Comments
 (0)