Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d8adce8

Browse files
committed
Check for malloc failure.
1 parent 25ee08e commit d8adce8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/backend/commands/sequence.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.56 2001/05/27 09:59:29 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.57 2001/06/01 19:52:24 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -646,8 +646,11 @@ init_sequence(char *caller, char *name)
646646
* as the backend does, so we use plain malloc for them.
647647
*/
648648
elm = (SeqTable) malloc(sizeof(SeqTableData));
649-
elm->name = malloc(strlen(name) + 1);
650-
strcpy(elm->name, name);
649+
if (elm == NULL)
650+
elog(ERROR, "Memory exhausted in init_sequence");
651+
elm->name = strdup(name);
652+
if (elm->name == NULL)
653+
elog(ERROR, "Memory exhausted in init_sequence");
651654
elm->rel = seqrel;
652655
elm->relid = RelationGetRelid(seqrel);
653656
elm->cached = elm->last = elm->increment = 0;

src/backend/lib/dllist.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.21 2001/02/10 02:31:26 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.22 2001/06/01 19:54:58 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -32,6 +32,8 @@ DLNewList(void)
3232
Dllist *l;
3333

3434
l = (Dllist *) malloc(sizeof(Dllist));
35+
if (l == NULL)
36+
elog(ERROR, "Memory exhausted in DLNewList");
3537
l->dll_head = 0;
3638
l->dll_tail = 0;
3739

@@ -66,6 +68,8 @@ DLNewElem(void *val)
6668
Dlelem *e;
6769

6870
e = (Dlelem *) malloc(sizeof(Dlelem));
71+
if (e == NULL)
72+
elog(ERROR, "Memory exhausted in DLNewElem");
6973
e->dle_next = 0;
7074
e->dle_prev = 0;
7175
e->dle_val = val;

0 commit comments

Comments
 (0)