rdo-postgres 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,7 +124,7 @@ static VALUE rdo_postgres_driver_quote(VALUE self, VALUE str) {
124
124
  "Unable to quote string: connection is not open");
125
125
  }
126
126
 
127
- char * quoted = malloc(sizeof(char) * RSTRING_LEN(str) * 4);
127
+ char * quoted = malloc(sizeof(char) * RSTRING_LEN(str) * 2 + 1);
128
128
  PQescapeStringConn(driver->conn_ptr, quoted,
129
129
  RSTRING_PTR(str), RSTRING_LEN(str), NULL);
130
130
 
@@ -8,6 +8,7 @@
8
8
  #include "params.h"
9
9
  #include <stdlib.h>
10
10
  #include <string.h>
11
+ #include <math.h>
11
12
 
12
13
  /** Get the strlen of the marker (e.g. $2) based on its index */
13
14
  #define RDO_PG_MARKER_LEN(n) (n >= 100 ? 4 : (n >= 10 ? 3 : 2))
@@ -20,7 +21,8 @@
20
21
  * This function is deliberately not broken apart, since it needs to be extremely fast.
21
22
  */
22
23
  char * rdo_postgres_params_inject_markers(char * stmt) {
23
- char * buf = malloc(sizeof(char) * strlen(stmt) * 4);
24
+ int len = strlen(stmt);
25
+ char * buf = malloc(sizeof(char) * len ? (len * (floor(log(len)) + 2)) : 0);
24
26
  char * s = stmt;
25
27
  char * b = buf;
26
28
  int n = 0;
@@ -7,6 +7,6 @@
7
7
 
8
8
  module RDO
9
9
  module Postgres
10
- VERSION = "0.0.5"
10
+ VERSION = "0.0.6"
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdo-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: