@@ -289,7 +289,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn)
289289 mysqlnd_set_persistent_string (& conn -> unix_socket , NULL , 0 , pers );
290290 DBG_INF_FMT ("scheme=%s" , conn -> scheme .s );
291291 mysqlnd_set_persistent_string (& conn -> scheme , NULL , 0 , pers );
292-
292+
293293 if (conn -> server_version ) {
294294 mnd_pefree (conn -> server_version , pers );
295295 conn -> server_version = NULL ;
@@ -725,19 +725,20 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
725725 DBG_RETURN (PASS );
726726 }
727727err :
728- if (transport .s ) {
729- mnd_sprintf_free (transport .s );
730- transport .s = NULL ;
731- }
732-
733- DBG_ERR_FMT ("[%u] %.128s (trying to connect via %s)" , conn -> error_info -> error_no , conn -> error_info -> error , conn -> scheme .s );
728+ DBG_ERR_FMT ("[%u] %.128s (trying to connect via %s)" , conn -> error_info -> error_no , conn -> error_info -> error , transport .s ? transport .s : conn -> scheme .s );
734729 if (!conn -> error_info -> error_no ) {
730+ /* There was an unknown error if the connection failed but we have no error number */
735731 char * msg ;
736- mnd_sprintf (& msg , 0 , "%s ( trying to connect via %s)" , conn -> error_info -> error , conn -> scheme .s );
732+ mnd_sprintf (& msg , 0 , "Unknown error while trying to connect via %s" , transport . s ? transport . s : conn -> scheme .s );
737733 SET_CLIENT_ERROR (conn -> error_info , CR_CONNECTION_ERROR , UNKNOWN_SQLSTATE , msg );
738734 mnd_sprintf_free (msg );
739735 }
740736
737+ if (transport .s ) {
738+ mnd_sprintf_free (transport .s );
739+ transport .s = NULL ;
740+ }
741+
741742 conn -> m -> free_contents (conn );
742743 MYSQLND_INC_CONN_STATISTIC (conn -> stats , STAT_CONNECT_FAILURE );
743744 DBG_RETURN (FAIL );
0 commit comments