summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-07-21 11:22:29 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-07-21 11:58:09 -0700
commit506cebe7bffb19f9310565b82231a08cc8e77ece (patch)
treedd46408c14d69075b37ef2f4ccc8ce270694c3e6
parentdd8c77a0c0d62ab88cf96ac507562469a7bcbc5a (diff)
XvQueryEncodings: avoid NULL deref if length is 0, but num_encodings is not
Found by gcc 14.1: Xv.c: In function ‘XvQueryEncodings’: Xv.c:387:31: warning: dereference of NULL ‘<unknown>’ [CWE-476] [-Wanalyzer-null-dereference] 387 | pe->encoding_id = u.pe->encoding; | ~~~~^~~~~~~~~~ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxv/-/merge_requests/7>
-rw-r--r--src/Xv.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Xv.c b/src/Xv.c
index 2a7e6c5..dc1e5f9 100644
--- a/src/Xv.c
+++ b/src/Xv.c
@@ -357,6 +357,10 @@ XvQueryEncodings(
}
_XRead(dpy, buffer, (long) size);
}
+ else if (rep.num_encodings != 0) {
+ status = XvBadReply;
+ goto out;
+ }
/* GET ENCODINGS */