<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8811">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_ooh323: Fix cppcheck warnings<br><br>Fix cppcheck warnings about redundant conditions and possible<br>null pointer usage<br><br>ASTERISK-27793 #close<br>Reported by: Ilya Shipitsin<br>Tested by: Ilya Shipitsin<br><br>Change-Id: I0b31933b062a23331dbac9a82b8bcfe345f406f6<br>---<br>M addons/chan_ooh323.c<br>M addons/ooh323c/src/context.c<br>M addons/ooh323c/src/memheap.c<br>M addons/ooh323c/src/ooCalls.c<br>M addons/ooh323c/src/ooCapability.c<br>M addons/ooh323c/src/ooGkClient.c<br>M addons/ooh323c/src/ooh245.c<br>M addons/ooh323c/src/ooq931.c<br>8 files changed, 17 insertions(+), 21 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c<br>index 278c587..8c5910d 100644<br>--- a/addons/chan_ooh323.c<br>+++ b/addons/chan_ooh323.c<br>@@ -5053,9 +5053,7 @@<br>                                         ast_log(LOG_NOTICE, "Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);<br>                          }<br>                             p->faxdetected = 1;<br>-                               if (dfr) {<br>-                                   ast_frfree(dfr);<br>-                             }<br>+                            ast_frfree(dfr);<br>                              return &ast_null_frame;<br>                   }<br>             }<br>diff --git a/addons/ooh323c/src/context.c b/addons/ooh323c/src/context.c<br>index bc3db43..c1e2003 100644<br>--- a/addons/ooh323c/src/context.c<br>+++ b/addons/ooh323c/src/context.c<br>@@ -164,6 +164,7 @@<br>          /* ASN1CRTFREE0 (pctxt); */<br>         ast_free(pctxt);<br>          pctxt = 0;<br>+         return (pctxt);<br>       }<br>       pctxt->flags |= ASN1DYNCTXT;<br>    }<br>diff --git a/addons/ooh323c/src/memheap.c b/addons/ooh323c/src/memheap.c<br>index 4bcbd7a..4020261 100644<br>--- a/addons/ooh323c/src/memheap.c<br>+++ b/addons/ooh323c/src/memheap.c<br>@@ -623,7 +623,7 @@<br>             }<br>          }<br>       }<br>-      if (!ISLAST (pElem) && ISFREE (GETNEXT (pElem))) {<br>+      if (pElem && !ISLAST (pElem) && ISFREE (GETNEXT (pElem))) {<br>          OSMemElemDescr* nextelem_p = GETNEXT (pElem);<br> <br>          /* +1 because the OSMemElemDescr has size ONE unit (8 bytes) */<br>@@ -638,7 +638,7 @@<br>       }<br> <br>       /* correct the prevOff field of next element */<br>-      if (!ISLAST (pElem)) {<br>+      if (pElem && !ISLAST (pElem)) {<br>          OSMemElemDescr* nextelem_p = GETNEXT (pElem);<br>          pElem_prevOff (nextelem_p) = QOFFSETOF (nextelem_p, pElem);<br>       }<br>@@ -686,7 +686,7 @@<br>    }<br> <br>    pNextElem = GETNEXT (pNewElem);<br>-   if (ISFREE (pNextElem)) {<br>+   if (pNextElem && ISFREE (pNextElem)) {<br> <br>       /* if the next elem is free, then unite them together */<br> <br>@@ -820,7 +820,7 @@<br>             /* look for free element after pElem */<br> <br>             pNextElem = GETNEXT (pElem);<br>-            if (ISFREE (pNextElem)) {<br>+            if (pNextElem && ISFREE (pNextElem)) {<br>                /* +1 'cos sizeof (OSMemElemDescr) == 1 unit */<br>                sumSize += pElem_nunits (pNextElem) + 1;<br>                freeMem++;<br>@@ -1062,7 +1062,7 @@<br> void memHeapRelease (void** ppvMemHeap)<br> {<br>    OSMemHeap** ppMemHeap = (OSMemHeap**)ppvMemHeap;<br>-   OSMemHeap* pMemHeap = *ppMemHeap;<br>+   OSMemHeap* pMemHeap;<br> <br>    if (ppMemHeap != 0 && *ppMemHeap != 0 && --(*ppMemHeap)->refCnt == 0) {<br>       OSMemLink* pMemLink, *pMemLink2;<br>@@ -1080,6 +1080,7 @@<br>       }<br> <br>       if ((*ppMemHeap)->flags & RT_MH_FREEHEAPDESC) {<br>+         pMemHeap = *ppMemHeap;<br>          ast_mutex_destroy(&pMemHeap->pLock);<br>          ast_free(*ppMemHeap);<br>       }<br>diff --git a/addons/ooh323c/src/ooCalls.c b/addons/ooh323c/src/ooCalls.c<br>index 3097c6d..15ab325 100644<br>--- a/addons/ooh323c/src/ooCalls.c<br>+++ b/addons/ooh323c/src/ooCalls.c<br>@@ -805,8 +805,7 @@<br> <br>    if(!call)<br>    {<br>-      OOTRACEERR3("Error:Invalid 'call' param for ooAddMediaInfo.(%s, %s)\n",<br>-                   call->callType, call->callToken);<br>+      OOTRACEERR1("Error:Invalid 'call' param for ooAddMediaInfo.\n");<br>       return OO_FAILED;<br>    }<br>    newMediaInfo = (OOMediaInfo*) memAlloc(call->pctxt, sizeof(OOMediaInfo));<br>diff --git a/addons/ooh323c/src/ooCapability.c b/addons/ooh323c/src/ooCapability.c<br>index 7314783..0796c46 100644<br>--- a/addons/ooh323c/src/ooCapability.c<br>+++ b/addons/ooh323c/src/ooCapability.c<br>@@ -62,8 +62,6 @@<br>       /*Dynamic RTP payload type range is from 96 - 127 */<br>       if(dynamicRTPPayloadType >= 96 && dynamicRTPPayloadType <= 127)<br>         gcDynamicRTPPayloadType = dynamicRTPPayloadType;<br>-      else<br>-        call->dtmfcodec = dynamicRTPPayloadType;<br>    }<br>    else{<br>       call->dtmfmode |= OO_CAP_DTMF_CISCO;<br>@@ -623,8 +621,7 @@<br>    else pctxt = call->pctxt;<br> <br>    epCap = (ooH323EpCapability*)memAllocZ(pctxt, sizeof(ooH323EpCapability));<br>-   params = (OOCapParams*) memAlloc(pctxt, sizeof(OOCapParams));<br>-   memset(params, 0 , sizeof(OOCapParams));<br>+   params = (OOCapParams*) memAllocZ(pctxt, sizeof(OOCapParams));<br>    if(!epCap || !params)<br>    {<br>       OOTRACEERR1("ERROR: Memory - ooCapabilityAddT38Capability - "<br>@@ -808,8 +805,7 @@<br>       }<br>       memset(pATECap, 0, sizeof(H245AudioTelephonyEventCapability));<br>       pATECap->dynamicRTPPayloadType = dtmfcodec;<br>-      events = (char*)memAlloc(pctxt, strlen("0-16")+1);<br>-      memset(events, 0, strlen("0-16")+1);<br>+      events = (char*)memAllocZ(pctxt, strlen("0-16")+1);<br>       if(!events)<br>       {<br>          OOTRACEERR1("Error:Memory - ooCapabilityCreateDTMFCapability - events\n");<br>diff --git a/addons/ooh323c/src/ooGkClient.c b/addons/ooh323c/src/ooGkClient.c<br>index a307f4e..0168ee7 100644<br>--- a/addons/ooh323c/src/ooGkClient.c<br>+++ b/addons/ooh323c/src/ooGkClient.c<br>@@ -2332,9 +2332,8 @@<br>    pIRR->m.perCallInfoPresent = TRUE;<br> <br>    perCallInfo =<br>-    (H225InfoRequestResponse_perCallInfo_element *)memAlloc(pctxt,<br>+    (H225InfoRequestResponse_perCallInfo_element *)memAllocZ(pctxt,<br>      sizeof(H225InfoRequestResponse_perCallInfo_element));<br>-   memset(perCallInfo, 0, sizeof(H225InfoRequestResponse_perCallInfo_element));<br> <br>    if(!perCallInfo)<br>    {<br>diff --git a/addons/ooh323c/src/ooh245.c b/addons/ooh323c/src/ooh245.c<br>index adff917..fe8ff28 100644<br>--- a/addons/ooh323c/src/ooh245.c<br>+++ b/addons/ooh323c/src/ooh245.c<br>@@ -356,7 +356,6 @@<br>    /* pctxt = &gH323ep.msgctxt; */<br>    pctxt = call->msgctxt;<br>    ph245msg->msgType = OOTerminalCapabilitySet;<br>-   memset(request, 0, sizeof(H245RequestMessage));<br>    if(request == NULL)<br>    {<br>       OOTRACEERR3("ERROR: No memory allocated for request message (%s, %s)\n",<br>@@ -364,6 +363,7 @@<br>       return OO_FAILED;<br>    }<br> <br>+   memset(request, 0, sizeof(H245RequestMessage));<br>    request->t = T_H245RequestMessage_terminalCapabilitySet;<br>    request->u.terminalCapabilitySet = (H245TerminalCapabilitySet*)<br>                   memAlloc(pctxt, sizeof(H245TerminalCapabilitySet));<br>diff --git a/addons/ooh323c/src/ooq931.c b/addons/ooh323c/src/ooq931.c<br>index 1ca361c..01a8e4a 100644<br>--- a/addons/ooh323c/src/ooq931.c<br>+++ b/addons/ooh323c/src/ooq931.c<br>@@ -2439,8 +2439,10 @@<br>       alias = call->pCallFwdData->aliases;<br>       while(alias)<br>       {<br>-         pNewAlias = (ooAliases*) memAlloc(pctxt, sizeof(ooAliases));<br>-         pNewAlias->value = (char*) memAlloc(pctxt, strlen(alias->value)+1);<br>+         pNewAlias = (ooAliases*) memAllocZ(pctxt, sizeof(ooAliases));<br>+         if (pNewAlias) {<br>+            pNewAlias->value = (char*) memAllocZ(pctxt, strlen(alias->value)+1);<br>+         }<br>          if(!pNewAlias || !pNewAlias->value)<br>          {<br>             OOTRACEERR3("Error:Memory - ooH323HandleCallFwdRequest - "<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8811">change 8811</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8811"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I0b31933b062a23331dbac9a82b8bcfe345f406f6 </div>
<div style="display:none"> Gerrit-Change-Number: 8811 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexander Anikin <may213@yandex.ru> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Matthew Fredrickson <creslin@digium.com> </div>