Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6ea8cc

Browse files
committed
Use abort() instead of exit() to abort library functions
In some hopeless situations, certain library functions in libpq andlibpgport quit the program. Use abort() for that instead of exit(),so we don't interfere with the normal exit codes the program mightuse, we clearly signal the abnormal termination, and the caller has achance of catching the termination.This was originally pointed out by Debian's Lintian program.
1 parent423ee49 commitc6ea8cc

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

‎src/interfaces/libpq/fe-print.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
112112
if (!(fieldNames= (constchar**)calloc(nFields,sizeof(char*))))
113113
{
114114
fprintf(stderr,libpq_gettext("out of memory\n"));
115-
exit(1);
115+
abort();
116116
}
117117
if (!(fieldNotNum= (unsignedchar*)calloc(nFields,1)))
118118
{
119119
fprintf(stderr,libpq_gettext("out of memory\n"));
120-
exit(1);
120+
abort();
121121
}
122122
if (!(fieldMax= (int*)calloc(nFields,sizeof(int))))
123123
{
124124
fprintf(stderr,libpq_gettext("out of memory\n"));
125-
exit(1);
125+
abort();
126126
}
127127
for (numFieldName=0;
128128
po->fieldName&&po->fieldName[numFieldName];
@@ -203,7 +203,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
203203
if (!(fields= (char**)calloc(nFields* (nTups+1),sizeof(char*))))
204204
{
205205
fprintf(stderr,libpq_gettext("out of memory\n"));
206-
exit(1);
206+
abort();
207207
}
208208
}
209209
elseif (po->header&& !po->html3)
@@ -391,7 +391,7 @@ do_field(const PQprintOpt *po, const PGresult *res,
391391
if (!(fields[i*nFields+j]= (char*)malloc(plen+1)))
392392
{
393393
fprintf(stderr,libpq_gettext("out of memory\n"));
394-
exit(1);
394+
abort();
395395
}
396396
strcpy(fields[i*nFields+j],pval);
397397
}
@@ -462,7 +462,7 @@ do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax,
462462
if (!border)
463463
{
464464
fprintf(stderr,libpq_gettext("out of memory\n"));
465-
exit(1);
465+
abort();
466466
}
467467
p=border;
468468
if (po->standard)
@@ -605,7 +605,7 @@ PQdisplayTuples(const PGresult *res,
605605
if (!fLength)
606606
{
607607
fprintf(stderr,libpq_gettext("out of memory\n"));
608-
exit(1);
608+
abort();
609609
}
610610

611611
for (j=0;j<nFields;j++)
@@ -704,7 +704,7 @@ PQprintTuples(const PGresult *res,
704704
if (!tborder)
705705
{
706706
fprintf(stderr,libpq_gettext("out of memory\n"));
707-
exit(1);
707+
abort();
708708
}
709709
for (i=0;i <=width;i++)
710710
tborder[i]='-';

‎src/interfaces/libpq/libpq-int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ extern pgthreadlock_t pg_g_threadlock;
483483
#definePGTHREAD_ERROR(msg) \
484484
do { \
485485
fprintf(stderr, "%s\n", msg); \
486-
exit(1); \
486+
abort(); \
487487
} while (0)
488488

489489

‎src/port/path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ get_progname(const char *argv0)
445445
if (progname==NULL)
446446
{
447447
fprintf(stderr,"%s: out of memory\n",nodir_name);
448-
exit(1);/* This could exit the postmaster */
448+
abort();/* This could exit the postmaster */
449449
}
450450

451451
#if defined(__CYGWIN__)|| defined(WIN32)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp