Re: Build failure with VS 2012 due to uninitialized pointers

From: "Inoue, Hiroshi" <inoue(at)tpf(dot)co(dot)jp>
To: Craig Ringer <craig(at)2ndquadrant(dot)com>, "pgsql-odbc(at)postgresql(dot)org" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: Build failure with VS 2012 due to uninitialized pointers
Date: 2014-06-14 13:36:54
Message-ID: 539C4FF6.2080906@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Thanks.
Confirmed and committed.

regards,
Hiroshi Inoue

(2014/06/12 16:53), Craig Ringer wrote:
> Hi folks
>
> VS 2012 reports possibly uninitialized pointer access:
>
>
>
>
> c:\users\administrator\desktop\psqlodbc\connection.c(2073): error C4703:
> potentially uninitialized local pointer variable 'sock' used
>
> which is
>
> if (0 != (sockerr = SOCK_get_errcode(sock)))
> {
>
> in original_CC_connect(...).
>
>
>
> c:\users\administrator\desktop\psqlodbc\dlg_wingui.c(177): error C4703:
> potentially uninitialized local pointer variable 'comval' used
>
> which is
>
> CheckDlgButton(hdlg, DRV_COMMLOG, comval->commlog);
>
>
>
>
> By default it treats these as fatal errors, so the codebase won't build
> on VS 2012. BuildAll.ps1 doesn't seem to provide a simple way to pass
> extra CFLAGS into the build (to pass /sdl- per
> http://msdn.microsoft.com/en-us/library/jj161081.aspx), and it isn't
> really desirable to just turn the warning off anyway.
>
>
> I've taken a look at what's going on. In the case of the first one the
> function is not small and its flow isn't simple. I thought I'd mention
> the issue here first, in case somebody was able to immediately see
> what's missing. While I could just:
>
>
> - SocketClass *sock;
> + SocketClass *sock = NULL;
>
> I'm pretty sure that's just papering over whatever the real problem is.
>
>
> The second, the comval error, looks to be a missing default: clause in
> the case. If this were backend code I'd just toss in an
>
> elog(FATAL,"Unreachable code reached");
>
> but that's not going to be much good in psqlODBC.

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message John Smith 2014-06-14 20:05:58 SQL_DATA_AT_EXEC fails for SQL_C_BIGINT and SQL_C_NUMERIC
Previous Message Craig Ringer 2014-06-14 09:16:04 Re: NPE in psqlodbc30a.dll!PgDtc_set_property caused by pgendlista.dll!IAsyncPG::RequestExec