| From: | Ranier Vilela <ranier_gyn(at)hotmail(dot)com> | 
|---|---|
| To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> | 
| Subject: | [PATCH][BUG FIX] Unsafe access pointers. | 
| Date: | 2019-11-15 11:25:07 | 
| Message-ID: | MN2PR18MB292725065DD177D4E34D3E9EE3700@MN2PR18MB2927.namprd18.prod.outlook.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
Hi,
Last time, I promise.
It's probably not happening, but it can happen, I think.
Best regards.
Ranier Vilela
--- \dll\postgresql-12.0\a\backend\access\brin\brin_validate.c	Mon Sep 30 17:06:55 2019
+++ brin_validate.c	Fri Nov 15 08:14:58 2019
@@ -57,8 +57,10 @@
 
 	/* Fetch opclass information */
 	classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid));
-	if (!HeapTupleIsValid(classtup))
+	if (!HeapTupleIsValid(classtup)) {
 		elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
+        return false;
+    }
 	classform = (Form_pg_opclass) GETSTRUCT(classtup);
 
 	opfamilyoid = classform->opcfamily;
@@ -67,8 +69,11 @@
 
 	/* Fetch opfamily information */
 	familytup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyoid));
-	if (!HeapTupleIsValid(familytup))
+	if (!HeapTupleIsValid(familytup)) {
 		elog(ERROR, "cache lookup failed for operator family %u", opfamilyoid);
+	    ReleaseSysCache(classtup);
+        return false;
+    }
 	familyform = (Form_pg_opfamily) GETSTRUCT(familytup);
 
 	opfamilyname = NameStr(familyform->opfname);
| Attachment | Content-Type | Size | 
|---|---|---|
| brin_validate.c.patch | application/octet-stream | 999 bytes | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Daniel Gustafsson | 2019-11-15 11:58:36 | Re: [PATCH][BUG FIX] Unsafe access pointers. | 
| Previous Message | Martin Liška | 2019-11-15 11:24:49 | Re: segfault in geqo on experimental gcc animal |