[pgadmin3][Patch] Null this in pgConn::GetStatus

From: Stuart Gathman <stuart(at)gathman(dot)org>
To: pgadmin-hackers(at)postgresql(dot)org
Subject: [pgadmin3][Patch] Null this in pgConn::GetStatus
Date: 2016-07-08 14:45:51
Message-ID: 342698cb-0974-6b40-dfdf-cc505601d9c9@gathman.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Saw the convention to tag for pgadmin3 and patch, so posting a 3rd time.
Sorry - new to pgadmin.

pgadmin3-1.22.1

When compiled with gcc6, the evil practice of "this == 0" fails
horribly. The most obvious effect is crashing during startup. I've
attached a simple patch. The Fedora bugzilla is here:

https://bugzilla.redhat.com/show_bug.cgi?id=1335043

A detailed explanation of why this == 0 is evil:
http://www.viva64.com/en/b/0226/

The patch moves the guts of pgConn::GetStatus() to a static function,
where comparing the ptr arg to 0 is well defined, and makes the
GetStatus() member function call the static function inline. It is
still technically undefined when calling the GetStatus member function
on a null ptr - but for now the compiler is not eliminating the test.
It is also a step in right direction, which would be to use the static
function at calling sites where the ptr could be null.

Attachment Content-Type Size
pgadmin3-nullthis.patch text/x-patch 1.1 KB

Browse pgadmin-hackers by date

  From Date Subject
Next Message Magnun Leno (Pessoal) 2016-07-08 16:07:40 Re: [Patch] Fix Unicode in errmsg
Previous Message Stuart Gathman 2016-07-08 14:43:00 Re: Where do I submit patches?