diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2012-01-30 21:34:00 +0200 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2012-01-30 21:34:00 +0200 |
commit | c6ea8ccea6bf23501962ddc7ac9ffdb99c8643e1 (patch) | |
tree | 30de0f6e9613755ca99ed755653f96b3bb375286 /src | |
parent | 423ee49b491ee966aa06259772dc38819cab786a (diff) | |
download | postgresql-c6ea8ccea6bf23501962ddc7ac9ffdb99c8643e1.tar.gz postgresql-c6ea8ccea6bf23501962ddc7ac9ffdb99c8643e1.zip |
Use abort() instead of exit() to abort library functions
In some hopeless situations, certain library functions in libpq and
libpgport quit the program. Use abort() for that instead of exit(),
so we don't interfere with the normal exit codes the program might
use, we clearly signal the abnormal termination, and the caller has a
chance of catching the termination.
This was originally pointed out by Debian's Lintian program.
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-print.c | 16 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-int.h | 2 | ||||
-rw-r--r-- | src/port/path.c | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index 8a854897b7c..6695492c7fc 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -112,17 +112,17 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) if (!(fieldNames = (const char **) calloc(nFields, sizeof(char *)))) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } if (!(fieldNotNum = (unsigned char *) calloc(nFields, 1))) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } if (!(fieldMax = (int *) calloc(nFields, sizeof(int)))) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } for (numFieldName = 0; po->fieldName && po->fieldName[numFieldName]; @@ -203,7 +203,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po) if (!(fields = (char **) calloc(nFields * (nTups + 1), sizeof(char *)))) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } } else if (po->header && !po->html3) @@ -391,7 +391,7 @@ do_field(const PQprintOpt *po, const PGresult *res, if (!(fields[i * nFields + j] = (char *) malloc(plen + 1))) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } strcpy(fields[i * nFields + j], pval); } @@ -462,7 +462,7 @@ do_header(FILE *fout, const PQprintOpt *po, const int nFields, int *fieldMax, if (!border) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } p = border; if (po->standard) @@ -605,7 +605,7 @@ PQdisplayTuples(const PGresult *res, if (!fLength) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } for (j = 0; j < nFields; j++) @@ -704,7 +704,7 @@ PQprintTuples(const PGresult *res, if (!tborder) { fprintf(stderr, libpq_gettext("out of memory\n")); - exit(1); + abort(); } for (i = 0; i <= width; i++) tborder[i] = '-'; diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h index d967d60f383..987311efc8d 100644 --- a/src/interfaces/libpq/libpq-int.h +++ b/src/interfaces/libpq/libpq-int.h @@ -483,7 +483,7 @@ extern pgthreadlock_t pg_g_threadlock; #define PGTHREAD_ERROR(msg) \ do { \ fprintf(stderr, "%s\n", msg); \ - exit(1); \ + abort(); \ } while (0) diff --git a/src/port/path.c b/src/port/path.c index 932206a1a6b..be55e4af60d 100644 --- a/src/port/path.c +++ b/src/port/path.c @@ -445,7 +445,7 @@ get_progname(const char *argv0) if (progname == NULL) { fprintf(stderr, "%s: out of memory\n", nodir_name); - exit(1); /* This could exit the postmaster */ + abort(); /* This could exit the postmaster */ } #if defined(__CYGWIN__) || defined(WIN32) |