help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: dbd-postgres: Make it possible to make safe queries


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: dbd-postgres: Make it possible to make safe queries
Date: Fri, 08 Apr 2011 15:24:19 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

Thanks!

I am only squashing this in:

diff --git a/packages/dbd-postgresql/Connection.st 
b/packages/dbd-postgresql/Connection.st
index 202e604..d2222ec 100644
--- a/packages/dbd-postgresql/Connection.st
+++ b/packages/dbd-postgresql/Connection.st
@@ -198,11 +198,11 @@ CObject subclass: PQConnection [
             ^ self error: 'All parameters must be strings here'].
 
         "Convert the params into an array of C-Strings."
-        par := CStringType new: params size.
+        ^[par := CStringType new: params size.
         1 to: params size do: [:each |
             par at: each - 1 put: (params at: each)].
 
-        [^ self
+        self
             exec_params:aSqlStatement
             n_par: params size
             types: nil
@@ -213,9 +213,9 @@ CObject subclass: PQConnection [
         ] ensure: [
             "Free the memory we allocated"
 
-            0 to: params size - 1 do: [:each |
-                (par derefAt: (each * CStringType sizeof) type: CObjectType) 
free
-            ].
+            par isNil ifFalse: [
+                0 to: params size - 1 do: [:each |
+                    ((par + each) derefAt: 0 type: CObjectType) free ].
 
             par free.
         ]

I'll probably add a utility method to CPtr for the derefAt:type: idiom.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]