Wrong client_con_st.con member declaration

Bug #917588 reported by Domingo Alvarez Duarte
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Drizzle
New
Undecided
Unassigned

Bug Description

Trying to use libdrizzle 2.0 on win32 with sqlite3 I found that the supplied examples doesn't work, the client segfualts because it refer to an unitilized con struct.

Studing the client example I found that the member con of client_con_st structure should be a pointer because on the example there is an attempt to delete it.

typedef struct
{
  drizzle_con_st *con; <<<<< pointer
  drizzle_result_st result;
  drizzle_column_st column;
  client_state state;
  uint64_t row;
} client_con_st;

-------
  for (x= 0; x < client.client_con_count; x++)
  {
    /* This may fail if there is other initialization that fails. See docs. */
    drizzle_con_st *con= drizzle_con_add_tcp(client.drizzle,
                                             host, port, user, password, db,
                                             client.mysql_protocol
                                             ? DRIZZLE_CON_MYSQL
                                             : DRIZZLE_CON_NONE);
    if (con == NULL)
    {
      CLIENT_ERROR("drizzle_con_add_tcp", 0, &client);
    }
    client.client_con_list[x].con = con; <<<<<< assign here as pointer because if not
    drizzle_con_set_context(client.client_con_list[x].con,
                            &(client.client_con_list[x]));

    if (client_process(&client, &(client.client_con_list[x])) == 1) <<<< it will segfault on further calls here
      wait_for_connections++;
  }
---------------

  for (x= 0; x < client.client_con_count; x++)
  {
    drizzle_con_free(&(client.client_con_list[x].con)); <<<<< try to delete
  }

Seems to be this that will work with con as a pointer:

for (x= 0; x < client.client_con_count; x++)
  {
    drizzle_con_free(client.client_con_list[x].con); <<<< pointer that will be deleted
  }

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.