[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-dev
Subject:    [Devel] unixodbc bugs
From:       Alex.Gradinar () cartel ! md (Alex Gradinar)
Date:       2006-02-28 16:32:09
Message-ID: 00e701c63c79$7eea9510$1b84f3c1 () alex
[Download RAW message or body]

1. function convert_rows in file res.c
while allocationg memery to columns of row in this code

==========
      CON_ROW(_h) = (strn*)pkg_malloc((int)columns);
==========
allocate only amount of bytes as number of columns,
but we have to allocate number of columns * sizeof struct strn
This is correct code
==========
      CON_ROW(_h) = (strn*)pkg_malloc((int)columns*sizeof(strn));
==========
2. function convert_rows in file res.c
while getting data from odbc in this code
==========
ret = SQLGetData(CON_RESULT(_h), i, SQL_C_CHAR,
        (CON_ROW(_h)[i-1]).s, 1024, &indicator);

==========
write 1024 bytes, but if we chage size of variable 's' in struct strn
we have to keep in mind that this number of bytes we have to change too.
This is correct code
==========
ret = SQLGetData(CON_RESULT(_h), i, SQL_C_CHAR,
        (CON_ROW(_h)[i-1]).s, sizeof((CON_ROW(_h)[i-1]).s), &indicator);

==========
3. function submit_query in dbase.c
in this code
==========
        if(CON_RESULT(_h))
        {
                ret = SQLFreeStmt(&CON_RESULT(_h), SQL_CLOSE);
                if (!SQL_SUCCEEDED(ret))
                {
                        LOG(L_ERR, "Statement allocation error %d\n",
                                (int)(long)CON_CONNECTION(_h));
                        extract_error("SQLAllocStmt", CON_CONNECTION(_h), 
SQL_HANDLE_DBC);
                        return ret;
                }
        }

==========
3.1. call the function SQLFreeStmt, but error about allocation

3.2. with my odbc driver (OpenLink) SQLFreeStmt returned Error
I recomend to change this code to
==========
        if(CON_RESULT(_h))
        {
            SQLFreeStmt(&CON_RESULT(_h), SQL_RESET_PARAMS);
            SQLFreeStmt(&CON_RESULT(_h), SQL_UNBIND);
            SQLFreeStmt(&CON_RESULT(_h), SQL_CLOSE);
            SQLFreeStmt(&CON_RESULT(_h), SQL_DROP)
        }
==========


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic