<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><div>HI, all :</div><div>Our developers says that if set NULL to the pointer ,it can be used after released , is it right ? Following the the code which is </div><div>reported by scan-build and the type is used after release , <strong>can anyone tell me how to fix the bug ?</strong></div><div><strong>Or is it the false positive ? </strong> please see the attathed .c file for the detail which is start line 896, end line 942.</div><div> Thanks all . </div><div><br><!--StartFragment --><div>
896 void MTT_ETPV_del(MTT_ETPV ** handle)<br>897 {<br>898 MTT_ETPV ** this = (MTT_ETPV**)handle;<br>899 if((*this)->sURL) JString_del(&(*this)->sURL);<br>6<br>¡û<br>Taking false branch <br>¡ú<br>900 if((*this)->stURLPV) JArray_del(&(*this)->stURLPV);<br>7<br>¡û<br>Taking false branch <br>¡ú<br>901 if((*this)->sID) JString_del(&(*this)->sID);<br>8<br>¡û<br>Taking false branch <br>¡ú<br>902 if((*this)->className) JceFree((*this)->className);<br>9<br>¡û<br>Taking false branch <br>¡ú<br>903 JceFree(*this);<br>10<br>¡û<br>Within the expansion of the macro 'JceFree':<br>¡ú<br>a<br>Memory is released<br><br>904 *this = NULL;<br>905 }<br>906 <br>907 Int32 MTT_ETPV_init(MTT_ETPV * handle)<br>908 {<br>909 MTT_ETPV * this = (MTT_ETPV*) handle;<br>910 <br>911 char * tafClassName = "MTT.ETPV";<br>912 <br>913 this->className = JceMalloc(strlen(tafClassName)+1);<br>914 this->writeTo = MTT_ETPV_writeTo;<br>915 this->readFrom = MTT_ETPV_readFrom;<br>916 <br>917 this->sURL = JString_new();<br>918 this->stURLPV = JArray_new("MTT.URLPV");<br>919 this->sID = JString_new();<br>920 <br>921 if(!this->className || !this->sURL || !this->stURLPV || !this->sID)<br>922 {<br>923 MTT_ETPV_del(&this);<br>5<br>¡û<br>Calling 'MTT_ETPV_del' <br>¡ú<br>11<br>¡û<br>Returning; memory was released <br>¡ú<br>924 return JCE_MALLOC_ERROR;<br>925 }<br>926 memcpy(this->className, tafClassName, strlen(tafClassName)+1);<br>927 <br>928 JString_assign(this->sURL, "", strlen(""));<br>929 JString_assign(this->sID, "", strlen(""));<br>930 <br>931 return JCE_SUCCESS;<br>932 }<br>933 <br>934 MTT_ETPV * MTT_ETPV_new()<br>935 {<br>936 Int32 ret=0;<br>937 MTT_ETPV *this = (MTT_ETPV *)JceMalloc(sizeof(MTT_ETPV));<br>1<br>Within the expansion of the macro 'JceMalloc':<br>¡ú<br>a<br>Memory is allocated<br><br>938 if(!this) return NULL;<br>2<br>¡û<br>Assuming 'this' is non-null <br>¡ú<br>3<br>¡û<br>Taking false branch <br>¡ú<br>939 ret = MTT_ETPV_init(this);<br>4<br>¡û<br>Calling 'MTT_ETPV_init' <br>¡ú<br>12<br>¡û<br>Returning; memory was released via 1st parameter <br>¡ú<br>940 if(JCE_SUCCESS != ret) { return NULL; }<br>13<br>¡û<br>Taking false branch <br>¡ú<br>941 return this;<br>14<br>¡û<br>Use of memory after it is freed<br>942 }<br>
</div> BRs</div><div><div>
<div>Howard Ling </div>
<div>*****************************************************</div>
<div> </div>
<div>E-mail: <a href="mailto:linghuan713@126.com">linghuan713@126.com</a></div>
<div> </div>
<div>*****************************************************</div></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>