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

List:       monetdb-checkins
Subject:    MonetDB: default - Cleanup in case of error.
From:       Sjoerd_Mullender <commits+sjoerd=acm.org () monetdb ! org>
Date:       2022-06-23 12:35:21
Message-ID: hg.d9904d0a41e6.1655987721.-7048037948960872877 () dev ! monetdb ! org
[Download RAW message or body]

Changeset: d9904d0a41e6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/d9904d0a41e6
Modified Files:
	gdk/gdk_bbp.c
Branch: default
Log Message:

Cleanup in case of error.


diffs (29 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3021,14 +3021,19 @@ BATdescriptor(bat i)
 			}
 		}
 		int refs;
-		if ((refs = incref(i, false, false)) <= 0)
-			return NULL;
-		b = BBP_cache(i);
-		if (b == NULL)
-			b = getBBPdescriptor(i);
+		if ((refs = incref(i, false, false)) > 0) {
+			b = BBP_cache(i);
+			if (b == NULL)
+				b = getBBPdescriptor(i);
+		} else {
+			/* if incref fails, we must return NULL */
+			b = NULL;
+		}
 		if (lock)
 			MT_lock_unset(&GDKswapLock(i));
-		if (refs > 1) {
+		if (refs != 1) {
+			/* unfix both in case of failure (<= 0) and when
+			 * not the first (> 1) */
 			if (tp != 0 && tp != i)
 				BBPunfix(tp);
 			if (tvp != 0 && tvp != i)
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-leave@monetdb.org
[prev in list] [next in list] [prev in thread] [next in thread] 

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