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?
--
Best regards,
Aleksander Alekseev
Looks like resource leak:
./src/backend/storage/buffer/localbuf.c: LocalBufferDescriptors =
(BufferDesc *) calloc(nbufs, sizeof(BufferDesc));
./src/backend/storage/buffer/localbuf.c: LocalBufferBlockPointers = (Block
*) calloc(nbufs, sizeof(Block));
./src/backend/storage/buffer/localbuf.c: LocalRefCount = (int32 *)
calloc(nbufs, sizeof(int32));
./src/backend/storage/buffer/localbuf.c- if (!LocalBufferDescriptors ||
!LocalBufferBlockPointers || !LocalRefCount)
./src/backend/storage/buffer/localbuf.c- ereport(FATAL,
./src/backend/storage/buffer/localbuf.c-
(errcode(ERRCODE_OUT_OF_MEMORY),
./src/backend/storage/buffer/localbuf.c- errmsg("out of
memory")));
./src/backend/storage/buffer/localbuf.c-
./src/interfaces/libpq/fe-print.c- nTups = PQntuples(res);
./src/interfaces/libpq/fe-print.c: if (!(fieldNames = (const char **)
calloc(nFields, sizeof(char *))))
./src/interfaces/libpq/fe-print.c- {
./src/interfaces/libpq/fe-print.c- fprintf(stderr, libpq_gettext("out
of memory\n"));
./src/interfaces/libpq/fe-print.c- abort();
./src/interfaces/libpq/fe-print.c- }
./src/interfaces/libpq/fe-print.c: if (!(fieldNotNum = (unsigned char *)
calloc(nFields, 1)))
./src/interfaces/libpq/fe-print.c- {
./src/interfaces/libpq/fe-print.c- fprintf(stderr, libpq_gettext("out
of memory\n"));
./src/interfaces/libpq/fe-print.c- abort();
./src/interfaces/libpq/fe-print.c- }
./src/interfaces/libpq/fe-print.c: if (!(fieldMax = (int *)
calloc(nFields, sizeof(int))))
./src/interfaces/libpq/fe-print.c- {
./src/interfaces/libpq/fe-print.c- fprintf(stderr, libpq_gettext("out
of memory\n"));
./src/interfaces/libpq/fe-print.c- abort();
./src/interfaces/libpq/fe-print.c- }
Two identical pieces of code:
./src/backend/bootstrap/bootstrap.c- scan =
heap_beginscan_catalog(rel, 0, NULL);
./src/backend/bootstrap/bootstrap.c- i = 0;
./src/backend/bootstrap/bootstrap.c- while ((tup =
heap_getnext(scan, ForwardScanDirection)) != NULL)
./src/backend/bootstrap/bootstrap.c- ++i;
./src/backend/bootstrap/bootstrap.c- heap_endscan(scan);
./src/backend/bootstrap/bootstrap.c: app = Typ = ALLOC(struct typmap
*, i + 1);
./src/backend/bootstrap/bootstrap.c- while (i-- > 0)
./src/backend/bootstrap/bootstrap.c: *app++ = ALLOC(struct
typmap, 1);
./src/backend/bootstrap/bootstrap.c- *app = NULL;
./src/backend/bootstrap/bootstrap.c- scan =
heap_beginscan_catalog(rel, 0, NULL);
./src/backend/bootstrap/bootstrap.c- app = Typ;
./src/backend/bootstrap/bootstrap.c- while ((tup =
heap_getnext(scan, ForwardScanDirection)) != NULL)
./src/backend/bootstrap/bootstrap.c- {
./src/backend/bootstrap/bootstrap.c- scan =
heap_beginscan_catalog(rel, 0, NULL);
./src/backend/bootstrap/bootstrap.c- i = 0;
./src/backend/bootstrap/bootstrap.c- while ((tup =
heap_getnext(scan, ForwardScanDirection)) != NULL)
./src/backend/bootstrap/bootstrap.c- ++i;
./src/backend/bootstrap/bootstrap.c- heap_endscan(scan);
./src/backend/bootstrap/bootstrap.c: app = Typ = ALLOC(struct typmap
*, i + 1);
./src/backend/bootstrap/bootstrap.c- while (i-- > 0)
./src/backend/bootstrap/bootstrap.c: *app++ = ALLOC(struct
typmap, 1);
./src/backend/bootstrap/bootstrap.c- *app = NULL;
./src/backend/bootstrap/bootstrap.c- scan =
heap_beginscan_catalog(rel, 0, NULL);
./src/backend/bootstrap/bootstrap.c- app = Typ;
./src/backend/bootstrap/bootstrap.c- while ((tup =
heap_getnext(scan, ForwardScanDirection)) != NULL)
./src/backend/bootstrap/bootstrap.c- {
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers