Bug Summary

File:home/maarten/src/libreoffice/core/registry/source/regkey.cxx
Warning:line 498, column 11
Dereference of null pointer (loaded from variable 'pLen')

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name regkey.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D REG_DLLIMPLEMENTATION -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/registry/inc -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/registry/source/regkey.cxx
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20
21#include "regkey.hxx"
22
23#include <osl/diagnose.h>
24#include "regimpl.hxx"
25#include "keyimpl.hxx"
26
27
28// acquireKey
29
30void REGISTRY_CALLTYPE acquireKey(RegKeyHandle hKey)
31{
32 ORegKey* pKey = static_cast< ORegKey* >(hKey);
33 if (pKey != nullptr)
34 {
35 ORegistry* pReg = pKey->getRegistry();
36 (void) pReg->acquireKey(pKey);
37 }
38}
39
40
41// releaseKey
42
43void REGISTRY_CALLTYPE releaseKey(RegKeyHandle hKey)
44{
45 ORegKey* pKey = static_cast< ORegKey* >(hKey);
46 if (pKey != nullptr)
47 {
48 ORegistry* pReg = pKey->getRegistry();
49 (void) pReg->releaseKey(pKey);
50 }
51}
52
53
54// isKeyReadOnly
55
56sal_Bool REGISTRY_CALLTYPE isKeyReadOnly(RegKeyHandle hKey)
57{
58 ORegKey* pKey = static_cast< ORegKey* >(hKey);
59 return pKey != nullptr && pKey->isReadOnly();
60}
61
62
63// getKeyName
64
65RegError REGISTRY_CALLTYPE getKeyName(RegKeyHandle hKey, rtl_uString** pKeyName)
66{
67 ORegKey* pKey = static_cast< ORegKey* >(hKey);
68 if (pKey)
69 {
70 rtl_uString_assign( pKeyName, pKey->getName().pData );
71 return RegError::NO_ERROR;
72 } else
73 {
74 rtl_uString_new(pKeyName);
75 return RegError::INVALID_KEY;
76 }
77}
78
79
80// createKey
81
82RegError REGISTRY_CALLTYPE createKey(RegKeyHandle hKey,
83 rtl_uString* keyName,
84 RegKeyHandle* phNewKey)
85{
86 *phNewKey = nullptr;
87
88 ORegKey* pKey = static_cast< ORegKey* >(hKey);
89 if (!pKey)
90 return RegError::INVALID_KEY;
91
92 if (pKey->isDeleted())
93 return RegError::INVALID_KEY;
94
95 if (pKey->isReadOnly())
96 return RegError::REGISTRY_READONLY;
97
98 return pKey->createKey(keyName, phNewKey);
99}
100
101
102// openKey
103
104RegError REGISTRY_CALLTYPE openKey(RegKeyHandle hKey,
105 rtl_uString* keyName,
106 RegKeyHandle* phOpenKey)
107{
108 *phOpenKey = nullptr;
109
110 ORegKey* pKey = static_cast< ORegKey* >(hKey);
111 if (!pKey)
112 return RegError::INVALID_KEY;
113
114 if (pKey->isDeleted())
115 return RegError::INVALID_KEY;
116
117 return pKey->openKey(keyName, phOpenKey);
118}
119
120
121// openSubKeys
122
123RegError REGISTRY_CALLTYPE openSubKeys(RegKeyHandle hKey,
124 rtl_uString* keyName,
125 RegKeyHandle** pphSubKeys,
126 sal_uInt32* pnSubKeys)
127{
128 *pphSubKeys = nullptr;
129 *pnSubKeys = 0;
130
131 ORegKey* pKey = static_cast< ORegKey* >(hKey);
132 if (!pKey)
133 return RegError::INVALID_KEY;
134
135 if (pKey->isDeleted())
136 return RegError::INVALID_KEY;
137
138 return pKey->openSubKeys(keyName, pphSubKeys, pnSubKeys);
139}
140
141
142// closeSubKeys
143
144RegError REGISTRY_CALLTYPE closeSubKeys(RegKeyHandle* phSubKeys,
145 sal_uInt32 nSubKeys)
146{
147 if (phSubKeys == nullptr || nSubKeys == 0)
148 return RegError::INVALID_KEY;
149
150 ORegistry* pReg = static_cast<ORegKey*>(phSubKeys[0])->getRegistry();
151 for (sal_uInt32 i = 0; i < nSubKeys; i++)
152 {
153 (void) pReg->closeKey(phSubKeys[i]);
154 }
155 std::free(phSubKeys);
156
157 return RegError::NO_ERROR;
158}
159
160
161// deleteKey
162
163RegError REGISTRY_CALLTYPE deleteKey(RegKeyHandle hKey,
164 rtl_uString* keyName)
165{
166 ORegKey* pKey = static_cast< ORegKey* >(hKey);
167 if (!pKey)
168 return RegError::INVALID_KEY;
169
170 if (pKey->isDeleted())
171 return RegError::INVALID_KEY;
172
173 if (pKey->isReadOnly())
174 return RegError::REGISTRY_READONLY;
175
176 return pKey->deleteKey(keyName);
177}
178
179
180// closeKey
181
182RegError REGISTRY_CALLTYPE closeKey(RegKeyHandle hKey)
183{
184 ORegKey* pKey = static_cast< ORegKey* >(hKey);
185 if (!pKey)
186 return RegError::INVALID_KEY;
187
188 return pKey->closeKey(hKey);
189}
190
191
192// setValue
193
194RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey,
195 rtl_uString* keyName,
196 RegValueType valueType,
197 RegValue pData,
198 sal_uInt32 valueSize)
199{
200 ORegKey* pKey = static_cast< ORegKey* >(hKey);
201 if (!pKey)
202 return RegError::INVALID_KEY;
203
204 if (pKey->isDeleted())
205 return RegError::INVALID_KEY;
206
207 if (pKey->isReadOnly())
208 return RegError::REGISTRY_READONLY;
209
210 OUString valueName("value");
211 if (keyName->length)
212 {
213 ORegKey* pSubKey = nullptr;
214 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
215 if (_ret1 != RegError::NO_ERROR)
216 return _ret1;
217
218 _ret1 = pSubKey->setValue(valueName, valueType, pData, valueSize);
219 if (_ret1 != RegError::NO_ERROR)
220 {
221 RegError _ret2 = pKey->closeKey(pSubKey);
222 if (_ret2 != RegError::NO_ERROR)
223 return _ret2;
224 else
225 return _ret1;
226 }
227
228 return pKey->closeKey(pSubKey);
229 }
230
231 return pKey->setValue(valueName, valueType, pData, valueSize);
232}
233
234
235// setLongValueList
236
237RegError REGISTRY_CALLTYPE setLongListValue(RegKeyHandle hKey,
238 rtl_uString* keyName,
239 sal_Int32 const * pValueList,
240 sal_uInt32 len)
241{
242 ORegKey* pKey = static_cast< ORegKey* >(hKey);
243 if (!pKey)
244 return RegError::INVALID_KEY;
245
246 if (pKey->isDeleted())
247 return RegError::INVALID_KEY;
248
249 if (pKey->isReadOnly())
250 return RegError::REGISTRY_READONLY;
251
252 OUString valueName("value");
253 if (keyName->length)
254 {
255 ORegKey* pSubKey = nullptr;
256 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
257 if (_ret1 != RegError::NO_ERROR)
258 return _ret1;
259
260 _ret1 = pSubKey->setLongListValue(valueName, pValueList, len);
261 if (_ret1 != RegError::NO_ERROR)
262 {
263 RegError _ret2 = pKey->closeKey(pSubKey);
264 if (_ret2 != RegError::NO_ERROR)
265 return _ret2;
266 else
267 return _ret1;
268 }
269
270 return pKey->closeKey(pSubKey);
271 }
272
273 return pKey->setLongListValue(valueName, pValueList, len);
274}
275
276
277// setStringValueList
278
279RegError REGISTRY_CALLTYPE setStringListValue(RegKeyHandle hKey,
280 rtl_uString* keyName,
281 char** pValueList,
282 sal_uInt32 len)
283{
284 ORegKey* pKey = static_cast< ORegKey* >(hKey);
285 if (!pKey)
286 return RegError::INVALID_KEY;
287
288 if (pKey->isDeleted())
289 return RegError::INVALID_KEY;
290
291 if (pKey->isReadOnly())
292 return RegError::REGISTRY_READONLY;
293
294 OUString valueName("value");
295 if (keyName->length)
296 {
297 ORegKey* pSubKey = nullptr;
298 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
299 if (_ret1 != RegError::NO_ERROR)
300 return _ret1;
301
302 _ret1 = pSubKey->setStringListValue(valueName, pValueList, len);
303 if (_ret1 != RegError::NO_ERROR)
304 {
305 RegError _ret2 = pKey->closeKey(pSubKey);
306 if (_ret2 != RegError::NO_ERROR)
307 return _ret2;
308 else
309 return _ret1;
310 }
311
312 return pKey->closeKey(pSubKey);
313 }
314
315 return pKey->setStringListValue(valueName, pValueList, len);
316}
317
318
319// setUnicodeValueList
320
321RegError REGISTRY_CALLTYPE setUnicodeListValue(RegKeyHandle hKey,
322 rtl_uString* keyName,
323 sal_Unicode** pValueList,
324 sal_uInt32 len)
325{
326 ORegKey* pKey = static_cast< ORegKey* >(hKey);
327 if (!pKey)
328 return RegError::INVALID_KEY;
329
330 if (pKey->isDeleted())
331 return RegError::INVALID_KEY;
332
333 if (pKey->isReadOnly())
334 return RegError::REGISTRY_READONLY;
335
336 OUString valueName("value");
337 if (keyName->length)
338 {
339 ORegKey* pSubKey = nullptr;
340 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
341 if (_ret1 != RegError::NO_ERROR)
342 return _ret1;
343
344 _ret1 = pSubKey->setUnicodeListValue(valueName, pValueList, len);
345 if (_ret1 != RegError::NO_ERROR)
346 {
347 RegError _ret2 = pKey->closeKey(pSubKey);
348 if (_ret2 != RegError::NO_ERROR)
349 return _ret2;
350 else
351 return _ret1;
352 }
353
354 return pKey->closeKey(pSubKey);
355 }
356
357 return pKey->setUnicodeListValue(valueName, pValueList, len);
358}
359
360
361// getValueInfo
362
363RegError REGISTRY_CALLTYPE getValueInfo(RegKeyHandle hKey,
364 rtl_uString* keyName,
365 RegValueType* pValueType,
366 sal_uInt32* pValueSize)
367{
368 *pValueType = RegValueType::NOT_DEFINED;
369 *pValueSize = 0;
370
371 ORegKey* pKey = static_cast< ORegKey* >(hKey);
372 if (!pKey)
373 return RegError::INVALID_KEY;
374
375 if (pKey->isDeleted())
376 return RegError::INVALID_KEY;
377
378 RegValueType valueType;
379 sal_uInt32 valueSize;
380
381 OUString valueName("value");
382 if (keyName->length)
383 {
384 ORegKey* pSubKey = nullptr;
385 RegError _ret = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
386 if (_ret != RegError::NO_ERROR)
387 return _ret;
388
389 if (pSubKey->getValueInfo(valueName, &valueType, &valueSize) != RegError::NO_ERROR)
390 {
391 (void) pKey->releaseKey(pSubKey);
392 return RegError::INVALID_VALUE;
393 }
394
395 *pValueType = valueType;
396 *pValueSize = valueSize;
397
398 return pKey->releaseKey(pSubKey);
399 }
400
401
402 if (pKey->getValueInfo(valueName, &valueType, &valueSize) != RegError::NO_ERROR)
403 {
404 return RegError::INVALID_VALUE;
405 }
406
407 *pValueType = valueType;
408 *pValueSize = valueSize;
409
410 return RegError::NO_ERROR;
411}
412
413
414// getValueInfo
415
416RegError REGISTRY_CALLTYPE getValue(RegKeyHandle hKey,
417 rtl_uString* keyName,
418 RegValue pValue)
419{
420 ORegKey* pKey = static_cast< ORegKey* >(hKey);
421 if (!pKey)
422 return RegError::INVALID_KEY;
423
424 if (pKey->isDeleted())
425 return RegError::INVALID_KEY;
426
427 OUString valueName("value");
428 if (keyName->length)
429 {
430 ORegKey* pSubKey = nullptr;
431 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
432 if (_ret1 != RegError::NO_ERROR)
433 return _ret1;
434
435 _ret1 = pSubKey->getValue(valueName, pValue);
436 if (_ret1 != RegError::NO_ERROR)
437 {
438 (void) pKey->releaseKey(pSubKey);
439 return _ret1;
440 }
441
442 return pKey->releaseKey(pSubKey);
443 }
444
445 return pKey->getValue(valueName, pValue);
446}
447
448
449// getLongValueList
450
451RegError REGISTRY_CALLTYPE getLongListValue(RegKeyHandle hKey,
452 rtl_uString* keyName,
453 sal_Int32** pValueList,
454 sal_uInt32* pLen)
455{
456 assert((pValueList != nullptr) && (pLen != nullptr) && "registry::getLongListValue(): invalid parameter")(static_cast <bool> ((pValueList != nullptr) &&
(pLen != nullptr) && "registry::getLongListValue(): invalid parameter"
) ? void (0) : __assert_fail ("(pValueList != nullptr) && (pLen != nullptr) && \"registry::getLongListValue(): invalid parameter\""
, "/home/maarten/src/libreoffice/core/registry/source/regkey.cxx"
, 456, __extension__ __PRETTY_FUNCTION__))
;
457 *pValueList = nullptr;
458 *pLen = 0;
459
460 ORegKey* pKey = static_cast< ORegKey* >(hKey);
461 if (!pKey)
462 return RegError::INVALID_KEY;
463
464 if (pKey->isDeleted())
465 return RegError::INVALID_KEY;
466
467 OUString valueName("value");
468 if (keyName->length)
469 {
470 ORegKey* pSubKey = nullptr;
471 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
472 if (_ret1 != RegError::NO_ERROR)
473 return _ret1;
474
475 _ret1 = pSubKey->getLongListValue(valueName, pValueList, pLen);
476 if (_ret1 != RegError::NO_ERROR)
477 {
478 (void) pKey->releaseKey(pSubKey);
479 return _ret1;
480 }
481
482 return pKey->releaseKey(pSubKey);
483 }
484
485 return pKey->getLongListValue(valueName, pValueList, pLen);
486}
487
488
489// getStringValueList
490
491RegError REGISTRY_CALLTYPE getStringListValue(RegKeyHandle hKey,
492 rtl_uString* keyName,
493 char*** pValueList,
494 sal_uInt32* pLen)
495{
496 OSL_PRECOND((pValueList != nullptr) && (pLen != nullptr), "registry::getStringListValue(): invalid parameter")do { if (true && (!((pValueList != nullptr) &&
(pLen != nullptr)))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/registry/source/regkey.cxx"
":" "496" ": "), "%s", "registry::getStringListValue(): invalid parameter"
); } } while (false)
;
1
Assuming the condition is true
2
Assuming pointer value is null
3
Taking true branch
4
Loop condition is false. Exiting loop
497 *pValueList = nullptr;
498 *pLen = 0;
5
Dereference of null pointer (loaded from variable 'pLen')
499
500 ORegKey* pKey = static_cast< ORegKey* >(hKey);
501 if (!pKey)
502 return RegError::INVALID_KEY;
503
504 if (pKey->isDeleted())
505 return RegError::INVALID_KEY;
506
507 OUString valueName("value");
508 if (keyName->length)
509 {
510 ORegKey* pSubKey = nullptr;
511 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
512 if (_ret1 != RegError::NO_ERROR)
513 return _ret1;
514
515 _ret1 = pSubKey->getStringListValue(valueName, pValueList, pLen);
516 if (_ret1 != RegError::NO_ERROR)
517 {
518 (void) pKey->releaseKey(pSubKey);
519 return _ret1;
520 }
521
522 return pKey->releaseKey(pSubKey);
523 }
524
525 return pKey->getStringListValue(valueName, pValueList, pLen);
526}
527
528// getUnicodeListValue
529RegError REGISTRY_CALLTYPE getUnicodeListValue(RegKeyHandle hKey,
530 rtl_uString* keyName,
531 sal_Unicode*** pValueList,
532 sal_uInt32* pLen)
533{
534 assert((pValueList != nullptr) && (pLen != nullptr) && "registry::getUnicodeListValue(): invalid parameter")(static_cast <bool> ((pValueList != nullptr) &&
(pLen != nullptr) && "registry::getUnicodeListValue(): invalid parameter"
) ? void (0) : __assert_fail ("(pValueList != nullptr) && (pLen != nullptr) && \"registry::getUnicodeListValue(): invalid parameter\""
, "/home/maarten/src/libreoffice/core/registry/source/regkey.cxx"
, 534, __extension__ __PRETTY_FUNCTION__))
;
535 *pValueList = nullptr;
536 *pLen = 0;
537
538 ORegKey* pKey = static_cast< ORegKey* >(hKey);
539 if (!pKey)
540 return RegError::INVALID_KEY;
541
542 if (pKey->isDeleted())
543 return RegError::INVALID_KEY;
544
545 OUString valueName("value");
546 if (keyName->length)
547 {
548 ORegKey* pSubKey = nullptr;
549 RegError _ret1 = pKey->openKey(keyName, reinterpret_cast<RegKeyHandle*>(&pSubKey));
550 if (_ret1 != RegError::NO_ERROR)
551 return _ret1;
552
553 _ret1 = pSubKey->getUnicodeListValue(valueName, pValueList, pLen);
554 if (_ret1 != RegError::NO_ERROR)
555 {
556 (void) pKey->releaseKey(pSubKey);
557 return _ret1;
558 }
559
560 return pKey->releaseKey(pSubKey);
561 }
562
563 return pKey->getUnicodeListValue(valueName, pValueList, pLen);
564}
565
566
567// freeValueList
568
569RegError REGISTRY_CALLTYPE freeValueList(RegValueType valueType,
570 RegValue pValueList,
571 sal_uInt32 len)
572{
573 switch (valueType)
574 {
575 case RegValueType::LONGLIST:
576 {
577 std::free(pValueList);
578 }
579 break;
580 case RegValueType::STRINGLIST:
581 {
582 char** pVList = static_cast<char**>(pValueList);
583 for (sal_uInt32 i=0; i < len; i++)
584 {
585 std::free(pVList[i]);
586 }
587
588 std::free(pVList);
589 }
590 break;
591 case RegValueType::UNICODELIST:
592 {
593 sal_Unicode** pVList = static_cast<sal_Unicode**>(pValueList);
594 for (sal_uInt32 i=0; i < len; i++)
595 {
596 std::free(pVList[i]);
597 }
598
599 std::free(pVList);
600 }
601 break;
602 default:
603 return RegError::INVALID_VALUE;
604 }
605
606 pValueList = nullptr;
607 return RegError::NO_ERROR;
608}
609
610
611// getName
612
613RegError REGISTRY_CALLTYPE getResolvedKeyName(RegKeyHandle hKey,
614 rtl_uString* keyName,
615 SAL_UNUSED_PARAMETER__attribute__ ((unused)) sal_Bool,
616 rtl_uString** pResolvedName)
617{
618 ORegKey* pKey = static_cast< ORegKey* >(hKey);
619 if (!pKey)
620 return RegError::INVALID_KEY;
621
622 if (pKey->isDeleted())
623 return RegError::INVALID_KEY;
624
625 OUString resolvedName;
626 RegError _ret = pKey->getResolvedKeyName(keyName, resolvedName);
627 if (_ret == RegError::NO_ERROR)
628 rtl_uString_assign(pResolvedName, resolvedName.pData);
629 return _ret;
630}
631
632
633// getKeyNames
634
635RegError REGISTRY_CALLTYPE getKeyNames(RegKeyHandle hKey,
636 rtl_uString* keyName,
637 rtl_uString*** pSubKeyNames,
638 sal_uInt32* pnSubKeys)
639{
640 ORegKey* pKey = static_cast< ORegKey* >(hKey);
641 if (!pKey)
642 return RegError::INVALID_KEY;
643
644 if (pKey->isDeleted())
645 return RegError::INVALID_KEY;
646
647 return pKey->getKeyNames(keyName, pSubKeyNames, pnSubKeys);
648}
649
650
651// freeKeyNames
652
653RegError REGISTRY_CALLTYPE freeKeyNames(rtl_uString** pKeyNames,
654 sal_uInt32 nKeys)
655{
656 for (sal_uInt32 i=0; i < nKeys; i++)
657 {
658 rtl_uString_release(pKeyNames[i]);
659 }
660
661 std::free(pKeyNames);
662
663 return RegError::NO_ERROR;
664}
665
666
667// C API
668
669
670// reg_openKey
671
672RegError REGISTRY_CALLTYPE reg_openKey(RegKeyHandle hKey,
673 rtl_uString* keyName,
674 RegKeyHandle* phOpenKey)
675{
676 if (!hKey)
677 return RegError::INVALID_KEY;
678
679 return openKey(hKey, keyName, phOpenKey);
680}
681
682
683// reg_closeKey
684
685RegError REGISTRY_CALLTYPE reg_closeKey(RegKeyHandle hKey)
686{
687 if (!hKey)
688 return RegError::INVALID_KEY;
689
690 return closeKey(hKey);
691}
692
693
694/* vim:set shiftwidth=4 softtabstop=4 expandtab: */