Browse Source

fixed mantis-1889, mantis-1890, mantis-1891 (errors in sphinx_set_field_weights, sphinx_set_index_weights, sphinx_add_filter_entry)

Ilya Kuznetsov 10 years ago
parent
commit
d408828305
1 changed files with 4 additions and 5 deletions
  1. 4 5
      api/libsphinxclient/sphinxclient.c

+ 4 - 5
api/libsphinxclient/sphinxclient.c

@@ -335,7 +335,6 @@ void sphinx_cleanup ( sphinx_client * client )
 	sphinx_free_results ( client );
 	client->num_results = 0;
 
-	client->num_results = 0;
 	safe_free ( client->response_buf );
 }
 
@@ -597,7 +596,7 @@ sphinx_bool sphinx_set_field_weights ( sphinx_client * client, int num_weights,
 	{
 		if ( num_weights<=0 )		set_error ( client, "invalid arguments (num_weights must be > 0)" );
 		else if ( !field_names )	set_error ( client, "invalid arguments (field_names must not be NULL)" );
-		else if ( !field_names )	set_error ( client, "invalid arguments (field_weights must not be NULL)" );
+		else if ( !field_weights )	set_error ( client, "invalid arguments (field_weights must not be NULL)" );
 		else						set_error ( client, "invalid arguments" );
 		return SPH_FALSE;
 	}
@@ -630,7 +629,7 @@ sphinx_bool sphinx_set_index_weights ( sphinx_client * client, int num_weights,
 	{
 		if ( num_weights<=0 )		set_error ( client, "invalid arguments (num_weights must be > 0)" );
 		else if ( !index_names )	set_error ( client, "invalid arguments (index_names must not be NULL)" );
-		else if ( !index_names )	set_error ( client, "invalid arguments (index_weights must not be NULL)" );
+		else if ( !index_weights )	set_error ( client, "invalid arguments (index_weights must not be NULL)" );
 		else						set_error ( client, "invalid arguments" );
 		return SPH_FALSE;
 	}
@@ -674,8 +673,8 @@ static struct st_filter * sphinx_add_filter_entry ( sphinx_client * client )
 	int len;
 	if ( client->num_filters>=client->max_filters )
 	{
-		len = ( client->max_filters<=0 ) ? client->num_filters + 8 : 2*client->max_filters;
-		len *= sizeof(struct st_filter);
+		client->max_filters = ( client->max_filters<=0 ) ? client->num_filters + 8 : 2*client->max_filters;
+		len = client->max_filters*sizeof(struct st_filter);
 		client->filters = realloc ( client->filters, len );
 		if ( !client->filters )
 		{