diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-11-06 09:57:21 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-11-06 12:16:01 +0000 |
commit | 0b3a807eadb8cb1e25556ddc25c9b722527314bb (patch) | |
tree | aca59a02ffa3f0dee423f2795f753ce82f91b17e /registry/tools | |
parent | eb02a55385c2f2e8cfeabeacb566c9fe630135f3 (diff) |
coverity#1338272 Uncaught exception
Change-Id: I5b2b7044c77de899ce8dc1e44f3673835bd3ce4c
Diffstat (limited to 'registry/tools')
-rw-r--r-- | registry/tools/regview.cxx | 90 |
1 files changed, 49 insertions, 41 deletions
diff --git a/registry/tools/regview.cxx b/registry/tools/regview.cxx index 5b2ae7d355b6..dcf3a8d3c435 100644 --- a/registry/tools/regview.cxx +++ b/registry/tools/regview.cxx @@ -34,71 +34,79 @@ int main( int argc, char * argv[] ) int __cdecl main( int argc, char * argv[] ) #endif { - RegHandle hReg; - RegKeyHandle hRootKey, hKey; - - if (argc < 2 || argc > 3) + try { - fprintf(stderr, "using: regview registryfile [keyName]\n"); - exit(1); - } + RegHandle hReg; + RegKeyHandle hRootKey, hKey; - OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) ); - if (reg_openRegistry(regName.pData, &hReg, RegAccessMode::READONLY) != RegError::NO_ERROR) - { - fprintf(stderr, "open registry \"%s\" failed\n", argv[1]); - exit(1); - } + if (argc < 2 || argc > 3) + { + fprintf(stderr, "using: regview registryfile [keyName]\n"); + exit(1); + } - if (reg_openRootKey(hReg, &hRootKey) == RegError::NO_ERROR) - { - if (argc == 3) + OUString regName( convertToFileUrl(argv[1], strlen(argv[1])) ); + if (reg_openRegistry(regName.pData, &hReg, RegAccessMode::READONLY) != RegError::NO_ERROR) { - OUString keyName( OUString::createFromAscii(argv[2]) ); - if (reg_openKey(hRootKey, keyName.pData, &hKey) == RegError::NO_ERROR) + fprintf(stderr, "open registry \"%s\" failed\n", argv[1]); + exit(1); + } + + if (reg_openRootKey(hReg, &hRootKey) == RegError::NO_ERROR) + { + if (argc == 3) { - if (reg_dumpRegistry(hKey) != RegError::NO_ERROR) + OUString keyName( OUString::createFromAscii(argv[2]) ); + if (reg_openKey(hRootKey, keyName.pData, &hKey) == RegError::NO_ERROR) { - fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); - } + if (reg_dumpRegistry(hKey) != RegError::NO_ERROR) + { + fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); + } - if (reg_closeKey(hKey) != RegError::NO_ERROR) + if (reg_closeKey(hKey) != RegError::NO_ERROR) + { + fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n", + argv[2], argv[1]); + } + } + else { - fprintf(stderr, "closing key \"%s\" of registry \"%s\" failed\n", + fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n", argv[2], argv[1]); } } else { - fprintf(stderr, "key \"%s\" not exists in registry \"%s\"\n", - argv[2], argv[1]); + if (reg_dumpRegistry(hRootKey) != RegError::NO_ERROR) + { + fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); + } + } + + if (reg_closeKey(hRootKey) != RegError::NO_ERROR) + { + fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]); } } else { - if (reg_dumpRegistry(hRootKey) != RegError::NO_ERROR) - { - fprintf(stderr, "dumping registry \"%s\" failed\n", argv[1]); - } + fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]); } - if (reg_closeKey(hRootKey) != RegError::NO_ERROR) + if (reg_closeRegistry(hReg) != RegError::NO_ERROR) { - fprintf(stderr, "closing root key of registry \"%s\" failed\n", argv[1]); + fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]); + exit(1); } - } - else - { - fprintf(stderr, "open root key of registry \"%s\" failed\n", argv[1]); - } - if (reg_closeRegistry(hReg) != RegError::NO_ERROR) + return 0; + } + catch (std::exception& e) { - fprintf(stderr, "closing registry \"%s\" failed\n", argv[1]); - exit(1); + fprintf(stderr, "failure: \"%s\"\n", e.what()); + return 1; } - - return 0; } |