Skip to content

Instantly share code, notes, and snippets.

@brianmario
Created July 9, 2013 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianmario/5961577 to your computer and use it in GitHub Desktop.
Save brianmario/5961577 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <string.h>
#include <mysql.h>
int main() {
MYSQL *client;
MYSQL_RES *result;
int err;
char *query = "SELECT 1";
client = mysql_init(NULL);
client = mysql_real_connect(client, "127.0.0.1",
"root", NULL,
NULL, 13306, "/opt/boxen/data/mysql/socket",
0);
err = mysql_real_query(client, query, strlen(query));
result = mysql_use_result(client);
mysql_close(client);
result->handle = (void*)1; // this line is the key, can't be NULL but has been freed
mysql_free_result(result);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment