Lists: | pgsql-hackers |
---|
From: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
Subject: | [PATCH] Fix NULL checking in check_TSCurrentConfig() |
Date: | 2013-01-20 04:51:26 |
Message-ID: | 1358657486-32676-1-git-send-email-xi.wang@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
The correct NULL check should use `*newval'; `newval' must be non-null.
---
src/backend/utils/cache/ts_cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c
index e688b1a..65a8ad7 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -642,7 +642,7 @@ check_TSCurrentConfig(char **newval, void **extra, GucSource source)
free(*newval);
*newval = strdup(buf);
pfree(buf);
- if (!newval)
+ if (!*newval)
return false;
}
--
1.7.10.4
From: | "Dickson S(dot) Guedes" <listas(at)guedesoft(dot)net> |
---|---|
To: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Fix NULL checking in check_TSCurrentConfig() |
Date: | 2013-01-20 14:48:16 |
Message-ID: | CAHHcrermpVwAFcheRkPyVO6pNb6cmHzHE4YzCA3eq5-Zdzh7HA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
2013/1/20 Xi Wang <xi(dot)wang(at)gmail(dot)com>:
> The correct NULL check should use `*newval'; `newval' must be non-null.
[... cutting code ...]
Please see [1] to know how is our submit patch process.
[1] http://wiki.postgresql.org/wiki/Submitting_a_Patch
regards,
--
Dickson S. Guedes
mail/xmpp: guedes(at)guedesoft(dot)net - skype: guediz
http://github.com/guedes - http://guedesoft.net
http://www.postgresql.org.br
From: | Stephen Frost <sfrost(at)snowman(dot)net> |
---|---|
To: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Fix NULL checking in check_TSCurrentConfig() |
Date: | 2013-01-20 15:39:53 |
Message-ID: | 20130120153952.GL16126@tamriel.snowman.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
* Xi Wang (xi(dot)wang(at)gmail(dot)com) wrote:
> The correct NULL check should use `*newval'; `newval' must be non-null.
Why isn't this using pstrdup()..?
Thanks,
Stephen
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stephen Frost <sfrost(at)snowman(dot)net> |
Cc: | Xi Wang <xi(dot)wang(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Fix NULL checking in check_TSCurrentConfig() |
Date: | 2013-01-21 03:34:21 |
Message-ID: | 6073.1358739261@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Stephen Frost <sfrost(at)snowman(dot)net> writes:
> * Xi Wang (xi(dot)wang(at)gmail(dot)com) wrote:
>> The correct NULL check should use `*newval'; `newval' must be non-null.
> Why isn't this using pstrdup()..?
The GUC API uses malloc, mainly because guc.c can't afford to lose
control on out-of-memory situations.
regards, tom lane
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Fix NULL checking in check_TSCurrentConfig() |
Date: | 2013-01-21 03:35:45 |
Message-ID: | 6109.1358739345@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Xi Wang <xi(dot)wang(at)gmail(dot)com> writes:
> The correct NULL check should use `*newval'; `newval' must be non-null.
Great catch, will commit. (But first I'm looking through commit
2594cf0e to see if I made the same mistake anywhere else :-(.)
How did you find that, coverity or some such tool?
regards, tom lane
From: | Xi Wang <xi(dot)wang(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [PATCH] Fix NULL checking in check_TSCurrentConfig() |
Date: | 2013-01-21 08:35:29 |
Message-ID: | 50FCFDD1.1070609@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 1/20/13 10:35 PM, Tom Lane wrote:
> Great catch, will commit. (But first I'm looking through commit
> 2594cf0e to see if I made the same mistake anywhere else :-(.)
>
> How did you find that, coverity or some such tool?
Thanks for reviewing the patch.
It was found using a homemade static undefined behavior checker.
- xi