Bruno Jesus : msacm32: Use a helper to validate stream pointers.

Alexandre Julliard julliard at winehq.org
Mon Aug 29 11:07:23 CDT 2016


Module: wine
Branch: master
Commit: 37f159e1cb26c3f3a666f76f76c1f8809538bbe3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=37f159e1cb26c3f3a666f76f76c1f8809538bbe3

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Sun Aug 28 04:07:30 2016 -0300

msacm32: Use a helper to validate stream pointers.

Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msacm32/stream.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/dlls/msacm32/stream.c b/dlls/msacm32/stream.c
index 4b4976f..6e81151 100644
--- a/dlls/msacm32/stream.c
+++ b/dlls/msacm32/stream.c
@@ -50,6 +50,15 @@ static PWINE_ACMSTREAM	ACM_GetStream(HACMSTREAM has)
     return (PWINE_ACMSTREAM)has;
 }
 
+static BOOL ACM_ValidatePointers(PACMDRVSTREAMHEADER padsh)
+{
+    /* check that pointers have not been modified */
+    return !(padsh->pbPreparedSrc != padsh->pbSrc ||
+             padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
+             padsh->pbPreparedDst != padsh->pbDst ||
+             padsh->cbPreparedDstLength < padsh->cbDstLength);
+}
+
 /***********************************************************************
  *           acmStreamClose (MSACM32.@)
  */
@@ -108,13 +117,9 @@ MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash,
      */
     padsh = (PACMDRVSTREAMHEADER)pash;
 
-    /* check that pointers have not been modified */
-    if (padsh->pbPreparedSrc != padsh->pbSrc ||
-	padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
-	padsh->pbPreparedDst != padsh->pbDst ||
-	padsh->cbPreparedDstLength < padsh->cbDstLength) {
+    if (!ACM_ValidatePointers(padsh)) {
         WARN("invalid parameter\n");
-	return MMSYSERR_INVALPARAM;
+        return MMSYSERR_INVALPARAM;
     }
 
     padsh->fdwConvert = fdwConvert;
@@ -467,13 +472,9 @@ MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash,
      */
     padsh = (PACMDRVSTREAMHEADER)pash;
 
-    /* check that pointers have not been modified */
-    if (padsh->pbPreparedSrc != padsh->pbSrc ||
-	padsh->cbPreparedSrcLength < padsh->cbSrcLength ||
-	padsh->pbPreparedDst != padsh->pbDst ||
-	padsh->cbPreparedDstLength < padsh->cbDstLength) {
+    if (!ACM_ValidatePointers(padsh)) {
         WARN("invalid parameter\n");
-	return MMSYSERR_INVALPARAM;
+        return MMSYSERR_INVALPARAM;
     }
 
     padsh->fdwConvert = fdwUnprepare;




More information about the wine-cvs mailing list