diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 10cc05d5e4b..42da83b9706 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -489,7 +489,7 @@ be_lo_export(PG_FUNCTION_ARGS) text *filename = PG_GETARG_TEXT_PP(1); int fd; int nbytes; - char buf[BUFSIZE]; + char *buf; char fnamebuf[MAXPGPATH]; LargeObjectDesc *lobj; mode_t oumask; @@ -525,6 +525,13 @@ be_lo_export(PG_FUNCTION_ARGS) errmsg("could not create server file \"%s\": %m", fnamebuf))); + /* + * The buffer is allocated rather than declared on the stack. A frame + * larger than 4kB that contains a PG_TRY() can be miscompiled by GCC on + * SPARC. + */ + buf = palloc(BUFSIZE); + /* * read in from the inversion file and write to the filesystem */ @@ -540,6 +547,8 @@ be_lo_export(PG_FUNCTION_ARGS) fnamebuf))); } + pfree(buf); + if (CloseTransientFile(fd) != 0) ereport(ERROR, (errcode_for_file_access(),