Skip site navigation (1) Skip section navigation (2)

Cure for segmentation fault in libpq

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: hackers(at)postgresql(dot)org, pgsql-questions(at)postgresql(dot)org
Subject: Cure for segmentation fault in libpq
Date: 1998-03-26 22:32:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
I have been troubled by a segmentation fault when reloading from a dumpall.
This has been happening when a second \connect is encountered. 

The faulty code was in fe-connect.c, where the memory for the user password
was freed, but the pointer itself was not set to NULL.  Later, the memory was
reused and the password appeared not to be empty, so that an attempt was
made to reference it.

Here is the patch:
diff -c postgresql-6.3.1{.orig,}/src/interfaces/libpq/fe-connect.c
*** postgresql-6.3.1.orig/src/interfaces/libpq/fe-connect.c     Thu Feb 26 
04:44:59 1998
--- postgresql-6.3.1/src/interfaces/libpq/fe-connect.c  Thu Mar 26 18:45:23 
*** 667,672 ****
--- 667,673 ----
        if (conn->pgpass != NULL)
+               conn->pgpass = NULL;
        return CONNECTION_OK;

Oliver Elphick                                Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight                    

PGP key from public servers; key ID 32B8FAA1


pgsql-hackers by date

Next:From: Bruce MomjianDate: 1998-03-26 23:45:23
Subject: Re: [HACKERS] Cure for segmentation fault in libpq
Previous:From: Bruce MomjianDate: 1998-03-26 20:53:06
Subject: Re: [HACKERS] Reference Guide

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group