Skip to content

Commit f1275ab

Browse files
committed
Escape without a connection no longer throws a segmentation fault
1 parent e42d003 commit f1275ab

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/node-db

src/connection.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ void node_db_mysql::Connection::close() {
125125
}
126126

127127
std::string node_db_mysql::Connection::escape(const std::string& string) const throw(node_db::Exception&) {
128+
if (!this->alive) {
129+
throw node_db::Exception("Can\'t escape string without an active connection");
130+
}
131+
128132
char* buffer = new char[string.length() * 2 + 1];
129133
if (buffer == NULL) {
130134
throw node_db::Exception("Can\'t create buffer to escape string");

0 commit comments

Comments
 (0)