snuk182 / odbc

Automatically exported from code.google.com/p/odbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Panic on VARCHAR column #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add the test case below to the typeTests unit tests
    {"select cast('' as varchar(5))", match("")},

What is the expected output? What do you see instead?
Fails with a panic on this line in func(c *BaseColumn) Value
p := unsafe.Pointer(&buf[0])

In this case, the varchar column's type is length 5 but the actual length of 
the returned data is 0.  The code in the Value() method attempts to get the 
first element of an array that has a length of 0 which causes a panic.

I think the solution is to only initialize p if the length of buf is greater 
than 0.

Original issue reported on code.google.com by lukemaul...@gmail.com on 1 May 2013 at 3:54

GoogleCodeExporter commented 9 years ago
Here https://codereview.appspot.com/9072044/ is a change as per your 
suggestion. Please, review it. Let me know, if I am stealing your thunder, and 
you want to do it yourself :-)

Alex

Original comment by alex.bra...@gmail.com on 2 May 2013 at 7:28

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 775d8f76e92c.

Original comment by alex.bra...@gmail.com on 3 May 2013 at 1:52