|
|
217285 |
From 416d7662a3f3ac5131014c6011bf1364d57a27e2 Mon Sep 17 00:00:00 2001
|
|
|
217285 |
From: Tobias Junghans <tobydox@veyon.io>
|
|
|
217285 |
Date: Tue, 3 Nov 2020 13:58:36 -0600
|
|
|
217285 |
Subject: [PATCH] libvncserver: add missing NULL pointer checks
|
|
|
217285 |
|
|
|
217285 |
---
|
|
|
217285 |
libvncserver/rfbregion.c | 26 ++++++++++++++++----------
|
|
|
217285 |
libvncserver/rfbserver.c | 4 +++-
|
|
|
217285 |
2 files changed, 19 insertions(+), 11 deletions(-)
|
|
|
217285 |
|
|
|
217285 |
diff --git a/libvncserver/rfbregion.c b/libvncserver/rfbregion.c
|
|
|
217285 |
index 1947d7c4..1e59646a 100644
|
|
|
217285 |
--- a/libvncserver/rfbregion.c
|
|
|
217285 |
+++ b/libvncserver/rfbregion.c
|
|
|
217285 |
@@ -50,24 +50,30 @@ sraSpanDup(const sraSpan *src) {
|
|
|
217285 |
|
|
|
217285 |
static void
|
|
|
217285 |
sraSpanInsertAfter(sraSpan *newspan, sraSpan *after) {
|
|
|
217285 |
- newspan->_next = after->_next;
|
|
|
217285 |
- newspan->_prev = after;
|
|
|
217285 |
- after->_next->_prev = newspan;
|
|
|
217285 |
- after->_next = newspan;
|
|
|
217285 |
+ if (newspan && after) {
|
|
|
217285 |
+ newspan->_next = after->_next;
|
|
|
217285 |
+ newspan->_prev = after;
|
|
|
217285 |
+ after->_next->_prev = newspan;
|
|
|
217285 |
+ after->_next = newspan;
|
|
|
217285 |
+ }
|
|
|
217285 |
}
|
|
|
217285 |
|
|
|
217285 |
static void
|
|
|
217285 |
sraSpanInsertBefore(sraSpan *newspan, sraSpan *before) {
|
|
|
217285 |
- newspan->_next = before;
|
|
|
217285 |
- newspan->_prev = before->_prev;
|
|
|
217285 |
- before->_prev->_next = newspan;
|
|
|
217285 |
- before->_prev = newspan;
|
|
|
217285 |
+ if (newspan && before) {
|
|
|
217285 |
+ newspan->_next = before;
|
|
|
217285 |
+ newspan->_prev = before->_prev;
|
|
|
217285 |
+ before->_prev->_next = newspan;
|
|
|
217285 |
+ before->_prev = newspan;
|
|
|
217285 |
+ }
|
|
|
217285 |
}
|
|
|
217285 |
|
|
|
217285 |
static void
|
|
|
217285 |
sraSpanRemove(sraSpan *span) {
|
|
|
217285 |
- span->_prev->_next = span->_next;
|
|
|
217285 |
- span->_next->_prev = span->_prev;
|
|
|
217285 |
+ if (span) {
|
|
|
217285 |
+ span->_prev->_next = span->_next;
|
|
|
217285 |
+ span->_next->_prev = span->_prev;
|
|
|
217285 |
+ }
|
|
|
217285 |
}
|
|
|
217285 |
|
|
|
217285 |
static void
|
|
|
217285 |
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
|
|
|
217285 |
index 1b4dd975..1f4230f2 100644
|
|
|
217285 |
--- a/libvncserver/rfbserver.c
|
|
|
217285 |
+++ b/libvncserver/rfbserver.c
|
|
|
217285 |
@@ -218,6 +218,8 @@ rfbClientIteratorHead(rfbClientIteratorPtr i)
|
|
|
217285 |
rfbClientPtr
|
|
|
217285 |
rfbClientIteratorNext(rfbClientIteratorPtr i)
|
|
|
217285 |
{
|
|
|
217285 |
+ if (!i)
|
|
|
217285 |
+ return NULL;
|
|
|
217285 |
if(i->next == 0) {
|
|
|
217285 |
LOCK(rfbClientListMutex);
|
|
|
217285 |
i->next = i->screen->clientHead;
|
|
|
217285 |
@@ -242,7 +244,7 @@ rfbClientIteratorNext(rfbClientIteratorPtr i)
|
|
|
217285 |
void
|
|
|
217285 |
rfbReleaseClientIterator(rfbClientIteratorPtr iterator)
|
|
|
217285 |
{
|
|
|
217285 |
- IF_PTHREADS(if(iterator->next) rfbDecrClientRef(iterator->next));
|
|
|
217285 |
+ IF_PTHREADS(if(iterator && iterator->next) rfbDecrClientRef(iterator->next));
|
|
|
217285 |
free(iterator);
|
|
|
217285 |
}
|
|
|
217285 |
|
|
|
217285 |
--
|
|
|
217285 |
2.28.0
|
|
|
217285 |
|