> Hello, Michael
> 
> > I don't know how you did it, but this email has visibly broken the
> > original thread. Did you change the topic name?
> 
> I'm very sorry for this. I had no local copy of this thread. So I wrote a
> new email with the same subject hoping it will be OK. Apparently right
> In-Reply-To header is also required. 
> 
> >   if (prodesc->user_proname == NULL || prodesc->internal_proname == NULL)
> > + {
> > +    free(prodesc);
> 
> I think that prodesc->user_proname and prodesc->internal_proname should
> also be freed if they are not NULL's.
> 
> > By the way maybe someone knows other procedures besides malloc, realloc
> > and strdup that require special attention?
> 
> I recalled that there is also calloc(). I've found four places that use
> calloc() and look suspicious to me (see attachment). What do you think -
> are these bugs or not?

I've just realized that there is also malloc-compatible ShmemAlloc().
Apparently it's return value sometimes is not properly checked too. See
attachment.

-- 
Best regards,
Aleksander Alekseev
./src/backend/access/transam/slru.c-        /* Initialize LWLocks */
./src/backend/access/transam/slru.c:        shared->buffer_locks = 
(LWLockPadded *) ShmemAlloc(sizeof(LWLockPadded) * nslots);
./src/backend/access/transam/slru.c-
./src/backend/access/transam/slru.c-        Assert(strlen(name) + 1 < 
SLRU_MAX_NAME_LENGTH);
./src/backend/access/transam/slru.c-        
strlcpy(shared->lwlock_tranche_name, name, SLRU_MAX_NAME_LENGTH);
./src/backend/access/transam/slru.c-        shared->lwlock_tranche_id = 
tranche_id;
./src/backend/access/transam/slru.c-        shared->lwlock_tranche.name = 
shared->lwlock_tranche_name;

./src/backend/postmaster/postmaster.c-void
./src/backend/postmaster/postmaster.c-ShmemBackendArrayAllocation(void)
./src/backend/postmaster/postmaster.c-{
./src/backend/postmaster/postmaster.c-  Size        size = 
ShmemBackendArraySize();
./src/backend/postmaster/postmaster.c-
./src/backend/postmaster/postmaster.c:  ShmemBackendArray = (Backend *) 
ShmemAlloc(size);
./src/backend/postmaster/postmaster.c-  /* Mark all slots as empty */
./src/backend/postmaster/postmaster.c-  memset(ShmemBackendArray, 0, size);
./src/backend/postmaster/postmaster.c-}

./src/backend/storage/ipc/shmem.c-  ShmemVariableCache = (VariableCache)
./src/backend/storage/ipc/shmem.c:      ShmemAlloc(sizeof(*ShmemVariableCache));
./src/backend/storage/ipc/shmem.c-  memset(ShmemVariableCache, 0, 
sizeof(*ShmemVariableCache));
./src/backend/storage/ipc/shmem.c-}

./src/backend/storage/lmgr/lwlock.c-        /* Allocate space */
./src/backend/storage/lmgr/lwlock.c:        ptr = (char *) 
ShmemAlloc(spaceLocks);
./src/backend/storage/lmgr/lwlock.c-
./src/backend/storage/lmgr/lwlock.c-        /* Leave room for dynamic 
allocation of tranches */
./src/backend/storage/lmgr/lwlock.c-        ptr += sizeof(int);

./src/backend/storage/lmgr/proc.c:  pgxacts = (PGXACT *) ShmemAlloc(TotalProcs 
* sizeof(PGXACT));
./src/backend/storage/lmgr/proc.c-  MemSet(pgxacts, 0, TotalProcs * 
sizeof(PGXACT));

./src/backend/storage/lmgr/proc.c-  /* Create ProcStructLock spinlock, too */
./src/backend/storage/lmgr/proc.c:  ProcStructLock = (slock_t *) 
ShmemAlloc(sizeof(slock_t));
./src/backend/storage/lmgr/proc.c-  SpinLockInit(ProcStructLock);

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to