Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
0.9.2
-
None
-
Linux CentOS 7.7
Description
The following code cause a core dump. This is due to the URI being badly formatted. The expected behavior would be to throw an exception.
#include <iostream>
|
#include <exception>
|
#include <ConnCpp.h>
|
#include <Exception.h>
|
|
int main(int argc, char *argv[]) |
{
|
sql::Driver* driver = sql::mariadb::get_driver_instance();
|
sql::Connection *conn;
|
sql::Statement *stmt;
|
|
try { |
conn = driver->connect("moe:3306", "user", "pwd"); |
stmt = conn->createStatement();
|
} catch(sql::SQLException &e) { |
std::cerr << "Exception: " << e.what() << "\n"; |
}
|
|
return 0; |
}
|
The error is in MariaDbDriver.cpp at:
Connection* MariaDbDriver::connect(const SQLString& url, Properties& props) |
{
|
UrlParser* urlParser= UrlParser::parse(url, props);
|
|
if (urlParser == nullptr || urlParser->getHostAddresses().empty()) |
{
|
==> return nullptr; |