- Description has changed:

Diff:

~~~~

--- old
+++ new
@@ -69,6 +69,66 @@
 [MEDIUM] /home/ubuntu/opensaf-code/src/imm/immnd/immnd_evt.c:4722:15: 
comparison of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned 
int') [clang-diagnostic-sign-compare]
         for (; ix < applArrSize && err == SA_AIS_OK;
                   ^
+[HIGH] /home/ubuntu/opensaf-code/src/imm/agent/imma_oi_api.cc:2815:10: Branch 
condition evaluates to a garbage value [core.uninitialized.Branch]
+  while (evt.info.immnd.info.objModify.attrMods) {
+         ^
+
+[HIGH] 
/home/ubuntu/opensaf-code/src/imm/apitest/management/test_saImmConfigSyncrTimeoutImma.c:40:3:
 Resource leak: f [cppcheck-resourceLeak]
+    return -1;
+    ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/ImmModel.cc:2265:15: Possible 
null pointer dereference: opName [cppcheck-nullPointer]
+  if ((strcmp(opName, "display") == 0)) {
+              ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/immnd_main.c:151:3: Common 
realloc mistake: 'result' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+    result = (char**)realloc(result, sizeof(char*) * ++n_elements);
+    ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/immnd_main.c:156:2: Common 
realloc mistake: 'result' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+  result = (char**)realloc(result, sizeof(char*) * (n_elements + 1));
+  ^
+
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_xmlw_dump.cc:644:37: Array 
access (via field 'attrValues') results in a null pointer dereference 
[core.NullDereference]
+    std::string str = valueToString(p->attrValues[i], p->attrValueType);
+                                    ^
+
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:598:4: Common realloc 
mistake: 'attrValues' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+      attrValues = realloc(attrValues,
+      ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:608:2: Common realloc 
mistake: 'attrValues' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+  attrValues =
+  ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:848:4: Common realloc 
mistake: 'attrMods' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+      attrMods = realloc(
+      ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:1770:4: Common 
realloc mistake: 'optargs' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+      optargs =
+      ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:1937:4: Common 
realloc mistake: 'classNames' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+      classNames =
+      ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:1983:4: Common 
realloc mistake: 'objectNames' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+      objectNames =
+      ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_import.cc:257:7: 1st 
function call argument is an uninitialized value [core.CallAndMessage]
+      free(((SaAnyT *)attrValue)->bufferAddr);
+      ^
+ 
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_import.cc:266:50: Array 
access (via field 'attrValues') results in a null pointer dereference 
[core.NullDereference]
+      free_attr_value(attrValues->attrValueType, attrValues->attrValues[i]);
+                                                 ^
+
+[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:513:4: Common 
realloc mistake: 'attributeNames' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
+      attributeNames = realloc(
+      ^
+
 
 
 ~~~

~~~~




---

**[tickets:#3376] imm: coding issues identified by codechecker**

**Status:** accepted
**Milestone:** 5.25.09
**Created:** Fri May 30, 2025 10:47 AM UTC by Thien Minh Huynh
**Last Updated:** Mon Jun 02, 2025 09:08 AM UTC
**Owner:** Thien Minh Huynh


~~~
[HIGH] /home/ubuntu/opensaf-code/src/imm/agent/imma_om_api.cc:7735:9: 
Dereference of null pointer [core.NullDereference]
    if (searchParam->searchOneAttr.attrValue) { /*free-3 */
        ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_admin.c:214:3: %llu in 
format string (no. 3) requires 'unsigned long long' but the argument type is 
'signed long long'. [cppcheck-invalidPrintfArgType_uint]
    printf("%-50s %-12s %llu (0x%llx, %s)\n", param->paramName,
    ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_admin.c:340:4: Common 
realloc mistake: 'params' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
      params = realloc(
      ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/apitest/implementer/applier.c:216:3: 
%u in format string (no. 1) requires 'unsigned int' but the argument type is 
'signed int'. [cppcheck-invalidPrintfArgType_uint]
    fprintf(stderr, "Reply on admin operation failed, err:%u\n",
    ^
[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:445:19: comparison 
of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned int') 
[clang-diagnostic-sign-compare]
        for (j = 0; j < attr->attrValuesNumber; j++) {
                      ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:448:18: comparison 
of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned int') 
[clang-diagnostic-sign-compare]
          if ((j + 1) < attr->attrValuesNumber)
                      ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:459:19: comparison 
of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned int') 
[clang-diagnostic-sign-compare]
        for (j = 0; j < attr->attrValuesNumber; j++) {
                      ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:463:18: comparison 
of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned int') 
[clang-diagnostic-sign-compare]
          if ((j + 1) < attr->attrValuesNumber)
                      ^
[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:249:17: comparison 
of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned int') 
[clang-diagnostic-sign-compare]
    for (i = 0; i < attrValues->attrValuesNumber; i++)
                  ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:264:17: comparison 
of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned int') 
[clang-diagnostic-sign-compare]
    for (i = 0; i < attrMod->modAttr.attrValuesNumber; i++) {
                  ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/ImmModel.cc:5405:32: Forming 
reference to null pointer [core.NonNullParamChecker]
              if (!release && (adm->mAdminOwnerName == oldOwner)) {
                               ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/ImmModel.cc:5450:41: Forming 
reference to null pointer [core.NonNullParamChecker]
                        if (!release && adm->mAdminOwnerName == oldOwner) {
                                        ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/ImmModel.cc:8975:21: Dereference 
of null pointer [core.NullDereference]
      if (!(strnlen(t->n.attrName.buf, t->n.attrName.size) == rdnAttrLen) ||
                    ^
[MEDIUM] /home/ubuntu/opensaf-code/src/imm/immloadd/imm_pbe_load.cc:257:5: %u 
in format string (no. 1) requires 'unsigned int' but the argument type is 
'signed int'. [cppcheck-invalidPrintfArgTyp
e_uint]
    snprintf(buf, 32, "Row(%u): <", ++r);
    ^
[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:106:3: %llu in 
format string (no. 1) requires 'unsigned long long' but the argument type is 
'signed long long'. [cppcheck-invalidPrintf
ArgType_uint]
    printf("%llu", *((SaTimeT *)attrValue));
    ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:171:3: %llu in 
format string (no. 1) requires 'unsigned long long' but the argument type is 
'signed long long'. [cppcheck-invalidPrintf
ArgType_uint]
    printf("%llu (0x%llx, %s)", *((SaTimeT *)attrValue),
    ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/apitest/management/populate.c:174:3: 
%u in format string (no. 2) requires 'unsigned int' but the argument type is 
'signed int'. [cppcheck-invalidPrintfArgType_uint]
    fprintf(stderr,
    ^

[MEDIUM] /home/ubuntu/opensaf-code/src/imm/immnd/immnd_evt.c:4722:15: 
comparison of integers of different signs: 'int' and 'SaUint32T' (aka 'unsigned 
int') [clang-diagnostic-sign-compare]
        for (; ix < applArrSize && err == SA_AIS_OK;
                  ^
[HIGH] /home/ubuntu/opensaf-code/src/imm/agent/imma_oi_api.cc:2815:10: Branch 
condition evaluates to a garbage value [core.uninitialized.Branch]
  while (evt.info.immnd.info.objModify.attrMods) {
         ^

[HIGH] 
/home/ubuntu/opensaf-code/src/imm/apitest/management/test_saImmConfigSyncrTimeoutImma.c:40:3:
 Resource leak: f [cppcheck-resourceLeak]
    return -1;
    ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/ImmModel.cc:2265:15: Possible 
null pointer dereference: opName [cppcheck-nullPointer]
  if ((strcmp(opName, "display") == 0)) {
              ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/immnd_main.c:151:3: Common 
realloc mistake: 'result' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
    result = (char**)realloc(result, sizeof(char*) * ++n_elements);
    ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/immnd/immnd_main.c:156:2: Common 
realloc mistake: 'result' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
  result = (char**)realloc(result, sizeof(char*) * (n_elements + 1));
  ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_xmlw_dump.cc:644:37: Array 
access (via field 'attrValues') results in a null pointer dereference 
[core.NullDereference]
    std::string str = valueToString(p->attrValues[i], p->attrValueType);
                                    ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:598:4: Common realloc 
mistake: 'attrValues' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
      attrValues = realloc(attrValues,
      ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:608:2: Common realloc 
mistake: 'attrValues' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
  attrValues =
  ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:848:4: Common realloc 
mistake: 'attrMods' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
      attrMods = realloc(
      ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:1770:4: Common realloc 
mistake: 'optargs' nulled but not freed upon failure [cppcheck-memleakOnRealloc]
      optargs =
      ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:1937:4: Common realloc 
mistake: 'classNames' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
      classNames =
      ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_cfg.c:1983:4: Common realloc 
mistake: 'objectNames' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
      objectNames =
      ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_import.cc:257:7: 1st 
function call argument is an uninitialized value [core.CallAndMessage]
      free(((SaAnyT *)attrValue)->bufferAddr);
      ^
 
[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_import.cc:266:50: Array 
access (via field 'attrValues') results in a null pointer dereference 
[core.NullDereference]
      free_attr_value(attrValues->attrValueType, attrValues->attrValues[i]);
                                                 ^

[HIGH] /home/ubuntu/opensaf-code/src/imm/tools/imm_list.c:513:4: Common realloc 
mistake: 'attributeNames' nulled but not freed upon failure 
[cppcheck-memleakOnRealloc]
      attributeNames = realloc(
      ^



~~~


---

Sent from sourceforge.net because [email protected] is 
subscribed to https://sourceforge.net/p/opensaf/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/opensaf/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.
_______________________________________________
Opensaf-tickets mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-tickets

Reply via email to