@@ -739,7 +739,8 @@ static int
739
739
pg_password_sendauth (PGconn * conn ,const char * password ,AuthRequest areq )
740
740
{
741
741
int ret ;
742
- char * crypt_pwd ;
742
+ char * crypt_pwd = NULL ;
743
+ const char * pwd_to_send ;
743
744
744
745
/* Encrypt the password if needed. */
745
746
@@ -771,21 +772,22 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
771
772
free (crypt_pwd );
772
773
return STATUS_ERROR ;
773
774
}
775
+
776
+ pwd_to_send = crypt_pwd ;
774
777
break ;
775
778
}
776
779
case AUTH_REQ_PASSWORD :
777
- /* discard const so we can assign it */
778
- crypt_pwd = (char * )password ;
780
+ pwd_to_send = password ;
779
781
break ;
780
782
default :
781
783
return STATUS_ERROR ;
782
784
}
783
785
/* Packet has a message type as of protocol 3.0 */
784
786
if (PG_PROTOCOL_MAJOR (conn -> pversion ) >=3 )
785
- ret = pqPacketSend (conn ,'p' ,crypt_pwd ,strlen (crypt_pwd )+ 1 );
787
+ ret = pqPacketSend (conn ,'p' ,pwd_to_send ,strlen (pwd_to_send )+ 1 );
786
788
else
787
- ret = pqPacketSend (conn ,0 ,crypt_pwd ,strlen (crypt_pwd )+ 1 );
788
- if (areq == AUTH_REQ_MD5 )
789
+ ret = pqPacketSend (conn ,0 ,pwd_to_send ,strlen (pwd_to_send )+ 1 );
790
+ if (crypt_pwd )
789
791
free (crypt_pwd );
790
792
return ret ;
791
793
}