Index: dll/cpl/desk/background.c =================================================================== --- dll/cpl/desk/background.c (revision 71259) +++ dll/cpl/desk/background.c (working copy) @@ -350,13 +350,13 @@ if ((result == ERROR_SUCCESS) && (_tcslen(originalWallpaper) > 0)) { hr = StringCbCopy(wallpaperFilename, sizeof(wallpaperFilename), originalWallpaper); + if (FAILED(hr)) + { + RegCloseKey(regKey); + return; + } } - if (FAILED(hr)) - { - RegCloseKey(regKey); - return; - } } /* Allow environment variables in file name */