Alex Henrie : mountmgr: Change scope of variable pvd in VOLUME_GetSuperblockLabel (cppcheck).

Alexandre Julliard julliard at winehq.org
Mon Dec 20 15:42:39 CST 2021


Module: wine
Branch: master
Commit: 656d7f58a11c53d2c1f5c0b6073324ecaded4088
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=656d7f58a11c53d2c1f5c0b6073324ecaded4088

Author: Alex Henrie <alexhenrie24 at gmail.com>
Date:   Sun Dec 19 21:54:21 2021 -0700

mountmgr: Change scope of variable pvd in VOLUME_GetSuperblockLabel (cppcheck).

The data in pvd was being accessed through the label_ptr variable after
pvd went out of scope.

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mountmgr.sys/device.c | 43 ++++++++++++++++++++-----------------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git a/dlls/mountmgr.sys/device.c b/dlls/mountmgr.sys/device.c
index d4f77012bbe..b8a0040195d 100644
--- a/dlls/mountmgr.sys/device.c
+++ b/dlls/mountmgr.sys/device.c
@@ -398,6 +398,7 @@ static void VOLUME_GetSuperblockLabel( struct volume *volume, HANDLE handle, con
 {
     const BYTE *label_ptr = NULL;
     DWORD label_len;
+    BYTE pvd[BLOCK_SIZE];
 
     switch (volume->fs_type)
     {
@@ -435,32 +436,28 @@ static void VOLUME_GetSuperblockLabel( struct volume *volume, HANDLE handle, con
             break;
         }
     case FS_UDF:
+        if(!UDF_Find_PVD(handle, pvd))
         {
-            BYTE pvd[BLOCK_SIZE];
-
-            if(!UDF_Find_PVD(handle, pvd))
-            {
-                label_len = 0;
-                break;
-            }
+            label_len = 0;
+            break;
+        }
 
-            /* [E] 3/10.1.4 and [U] 2.1.1 */
-            if(pvd[24]==8)
-            {
-                label_ptr = pvd + 24 + 1;
-                label_len = pvd[24+32-1];
-                break;
-            }
-            else
-            {
-                unsigned int i;
+        /* [E] 3/10.1.4 and [U] 2.1.1 */
+        if(pvd[24]==8)
+        {
+            label_ptr = pvd + 24 + 1;
+            label_len = pvd[24+32-1];
+            break;
+        }
+        else
+        {
+            unsigned int i;
 
-                label_len = 1 + pvd[24+32-1];
-                for (i = 0; i < label_len; i += 2)
-                    volume->label[i/2] = (pvd[24+1+i] << 8) | pvd[24+1+i+1];
-                volume->label[label_len] = 0;
-                return;
-            }
+            label_len = 1 + pvd[24+32-1];
+            for (i = 0; i < label_len; i += 2)
+                volume->label[i/2] = (pvd[24+1+i] << 8) | pvd[24+1+i+1];
+            volume->label[label_len] = 0;
+            return;
         }
     }
     if (label_len) RtlMultiByteToUnicodeN( volume->label, sizeof(volume->label) - sizeof(WCHAR),




More information about the wine-cvs mailing list