]> source.dussan.org Git - tigervnc.git/commitdiff
[Bugfix] Extend encoding range checks to handle negative encodings well.
authorAdam Tkac <atkac@redhat.com>
Wed, 21 Jul 2010 14:12:18 +0000 (14:12 +0000)
committerAdam Tkac <atkac@redhat.com>
Wed, 21 Jul 2010 14:12:18 +0000 (14:12 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4113 3789f03b-4d11-0410-bbf8-ca57d06f2519

common/rfb/ConnParams.cxx
common/rfb/Encoder.cxx

index 9bfc302729e9544c652cf362959e7a0971658485..3ee37087fc1aa9b43209f6a06edb00db172e1bca 100644 (file)
@@ -129,7 +129,7 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings)
               encodings[i] <= pseudoEncodingQualityLevel9) {
       noJpeg = false;
       qualityLevel = encodings[i] - pseudoEncodingQualityLevel0;
-    } else if (encodings[i] <= encodingMax && Encoder::supported(encodings[i]))
+    } else if (Encoder::supported(encodings[i]))
       currentEncoding_ = encodings[i];
   }
 }
index b0bd147e0af89e705ad2c6bdf695fef7c5b65e49..5de75430af7645878025b243dda60531bb7e8cbd 100644 (file)
@@ -34,12 +34,12 @@ EncoderCreateFnType Encoder::createFns[encodingMax+1] = { 0 };
 
 bool Encoder::supported(int encoding)
 {
-  return encoding <= encodingMax && createFns[encoding];
+  return encoding >= 0 && encoding <= encodingMax && createFns[encoding];
 }
 
 Encoder* Encoder::createEncoder(int encoding, SMsgWriter* writer)
 {
-  if (encoding <= encodingMax && createFns[encoding])
+  if (supported(encoding))
     return (*createFns[encoding])(writer);
   return 0;
 }