[PATCH 1/7] WINGs: WMIsPL* functions return False if proplist is null.

Doug Torrance <[email protected]> Fri, 18 Aug 2017 20:37:45 -0400
Newsgroups gmane.compw.window-managers.windowmaker.devel
Message-ID <[email protected]>
Previously, calls to WMIsPLString, WMIsPLData, WMIsPLArray, and
WMIsPLDictionary would result in a segfault if the argument was null.
This could happen, e.g., if we are checking which type of proplist
was just parsed from a file, but the parsing failed.

These functions now return False in this case.
---
 WINGs/proplist.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/WINGs/proplist.c b/WINGs/proplist.c
index 5f68eace..55188964 100644
--- a/WINGs/proplist.c
+++ b/WINGs/proplist.c
@@ -1253,22 +1253,34 @@ int WMGetPropListItemCount(WMPropList * plist)
 
 Bool WMIsPLString(WMPropList * plist)
 {
-	return (plist->type == WPLString);
+	if (plist)
+		return (plist->type == WPLString);
+	else
+		return False;
 }
 
 Bool WMIsPLData(WMPropList * plist)
 {
-	return (plist->type == WPLData);
+	if (plist)
+		return (plist->type == WPLData);
+	else
+		return False;
 }
 
 Bool WMIsPLArray(WMPropList * plist)
 {
-	return (plist->type == WPLArray);
+	if (plist)
+		return (plist->type == WPLArray);
+	else
+		return False;
 }
 
 Bool WMIsPLDictionary(WMPropList * plist)
 {
-	return (plist->type == WPLDictionary);
+	if (plist)
+		return (plist->type == WPLDictionary);
+	else
+		return False;
 }
 
 Bool WMIsPropListEqualTo(WMPropList * plist, WMPropList * other)
-- 
2.11.0


-- 
To unsubscribe, send mail to [email protected].