Skip to content

Commit cb564e3

Browse files
braxtonesodabrew
authored andcommitted
Add parameter type check when initializing Mysql2::Client (brianmario#792)
Fix for segfault when initializing a Mysql2::Client reported in issue brianmario#782
1 parent deda0c7 commit cb564e3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.rubocop.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ Style/TrailingComma:
2222
Style/TrivialAccessors:
2323
AllowPredicates: true
2424

25+
Metrics/AbcSize:
26+
Max: 82
27+
28+
Metrics/CyclomaticComplexity:
29+
Max: 28
30+
31+
Metrics/MethodLength:
32+
Max: 55
33+
2534
# TODO: remove when we end support for < 1.9.3
2635

2736
Style/HashSyntax:

lib/mysql2/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def self.default_query_options
1919
end
2020

2121
def initialize(opts = {})
22+
fail Mysql2::Error, "Options parameter must be a Hash" unless opts.is_a? Hash
2223
opts = Mysql2::Util.key_hash_as_symbols(opts)
2324
@read_timeout = nil
2425
@query_options = self.class.default_query_options.dup

0 commit comments

Comments
 (0)