Navigation


Changeset 1151:100a0925f809 in freeDiameter for extensions


Ignore:
Timestamp:
May 22, 2013, 10:37:48 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Fix a number of issues reported by cppcheck: http://lists.freediameter.net/pipermail/dev/2013-May/000214.html

Location:
extensions/app_diameap
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_diameap/diameap_eap.c

    r1075 r1151  
    9292        *vendor = 0;
    9393        *eaptype = TYPE_NONE;
     94        if (eap_sm == NULL)
     95        {
     96                return EINVAL;
     97        }
     98
    9499        eap_sm->selectedMethod = NULL;
    95 
    96         if (eap_sm == NULL)
    97         {
    98                 return EINVAL;
    99         }
    100100
    101101        if (eap_sm->user.userid == NULL)
  • extensions/app_diameap/diameap_server.c

    r1120 r1151  
    11311131static void free_ans_attrib(struct avp_attribute * ans_attrib)
    11321132{
    1133         if (ans_attrib->tofree == 1)
    1134         {
    1135                 if(ans_attrib->value.os.data){
    1136                 free(ans_attrib->value.os.data);
    1137                 ans_attrib->value.os.data = NULL;
    1138                 }
    1139         }
    11401133        if(ans_attrib){
    1141         free(ans_attrib);
    1142         ans_attrib = NULL;
     1134                if (ans_attrib->tofree == 1)
     1135                {
     1136                        if(ans_attrib->value.os.data){
     1137                        free(ans_attrib->value.os.data);
     1138                        ans_attrib->value.os.data = NULL;
     1139                        }
     1140                }
     1141                free(ans_attrib);
     1142                ans_attrib = NULL;
    11431143        }
    11441144}
     
    11851185{
    11861186
    1187         if (diameap_sm->eap_sm.user.userid != NULL)
    1188         {
    1189                 free(diameap_sm->eap_sm.user.userid);
    1190                 diameap_sm->eap_sm.user.userid = NULL;
    1191         }
    1192 
    1193         if (diameap_sm->eap_sm.user.password != NULL)
    1194         {
    1195                 free(diameap_sm->eap_sm.user.password);
    1196                 diameap_sm->eap_sm.user.password = NULL;
    1197         }
    1198 
    1199         diameap_sm->eap_sm.selectedMethod = NULL;
    1200 
    1201         if (diameap_sm->eap_sm.methodData != NULL)
    1202         {
    1203 
    1204                 struct plugin * cplugin;
    1205                 if (diameap_plugin_get(diameap_sm->eap_sm.currentVendor,
    1206                                 diameap_sm->eap_sm.currentMethod, &cplugin))
    1207                 {
    1208                         TRACE_DEBUG(INFO,"%sUnable to access EAP Method plugin {Type=%d, Vendor=%d}.",DIAMEAP_EXTENSION,diameap_sm->eap_sm.currentMethod,diameap_sm->eap_sm.currentVendor);
    1209                 }
    1210 
    1211                 if (cplugin->eap_method_free)
    1212                 {
    1213                         (*cplugin->eap_method_free)(diameap_sm->eap_sm.methodData);
    1214                         diameap_sm->eap_sm.methodData = NULL;
    1215                 }
    1216                 else
    1217                 {
    1218                         TRACE_DEBUG(INFO,"%s[%s plugin] datafree function not available.",DIAMEAP_EXTENSION,cplugin->methodname);
    1219                         if (diameap_sm->eap_sm.methodData != NULL)
    1220                         {
    1221                                 free(diameap_sm->eap_sm.methodData);
     1187        if (diameap_sm != NULL)
     1188        {
     1189                if (diameap_sm->eap_sm.user.userid != NULL)
     1190                {
     1191                        free(diameap_sm->eap_sm.user.userid);
     1192                        diameap_sm->eap_sm.user.userid = NULL;
     1193                }
     1194
     1195                if (diameap_sm->eap_sm.user.password != NULL)
     1196                {
     1197                        free(diameap_sm->eap_sm.user.password);
     1198                        diameap_sm->eap_sm.user.password = NULL;
     1199                }
     1200
     1201                diameap_sm->eap_sm.selectedMethod = NULL;
     1202
     1203                if (diameap_sm->eap_sm.methodData != NULL)
     1204                {
     1205
     1206                        struct plugin * cplugin;
     1207                        if (diameap_plugin_get(diameap_sm->eap_sm.currentVendor,
     1208                                        diameap_sm->eap_sm.currentMethod, &cplugin))
     1209                        {
     1210                                TRACE_DEBUG(INFO,"%sUnable to access EAP Method plugin {Type=%d, Vendor=%d}.",DIAMEAP_EXTENSION,diameap_sm->eap_sm.currentMethod,diameap_sm->eap_sm.currentVendor);
     1211                        }
     1212
     1213                        if (cplugin->eap_method_free)
     1214                        {
     1215                                (*cplugin->eap_method_free)(diameap_sm->eap_sm.methodData);
    12221216                                diameap_sm->eap_sm.methodData = NULL;
    12231217                        }
    1224                 }
    1225                 if (diameap_sm->eap_sm.methodData)
    1226                 {
    1227                         TRACE_DEBUG(INFO,"%sSession state was not been freed correctly!!!",DIAMEAP_EXTENSION);
    1228                 }
    1229         }
    1230 
    1231         if (diameap_sm->failedavp != NULL)
    1232         {
    1233                 CHECK_FCT_DO(fd_msg_free(diameap_sm->failedavp), );
    1234         }
    1235 
    1236         if (diameap_sm->lastReqEAPavp != NULL)
    1237         {
    1238                 CHECK_FCT_DO(fd_msg_free(diameap_sm->lastReqEAPavp), );
    1239         }
    1240 
    1241         CHECK_FCT_DO(diameap_unlink_attributes_lists(diameap_sm), );
    1242 
    1243         if (diameap_sm != NULL)
    1244         {
     1218                        else
     1219                        {
     1220                                TRACE_DEBUG(INFO,"%s[%s plugin] datafree function not available.",DIAMEAP_EXTENSION,cplugin->methodname);
     1221                                if (diameap_sm->eap_sm.methodData != NULL)
     1222                                {
     1223                                        free(diameap_sm->eap_sm.methodData);
     1224                                        diameap_sm->eap_sm.methodData = NULL;
     1225                                }
     1226                        }
     1227                        if (diameap_sm->eap_sm.methodData)
     1228                        {
     1229                                TRACE_DEBUG(INFO,"%sSession state was not been freed correctly!!!",DIAMEAP_EXTENSION);
     1230                        }
     1231                }
     1232
     1233                if (diameap_sm->failedavp != NULL)
     1234                {
     1235                        CHECK_FCT_DO(fd_msg_free(diameap_sm->failedavp), );
     1236                }
     1237
     1238                if (diameap_sm->lastReqEAPavp != NULL)
     1239                {
     1240                        CHECK_FCT_DO(fd_msg_free(diameap_sm->lastReqEAPavp), );
     1241                }
     1242
     1243                CHECK_FCT_DO(diameap_unlink_attributes_lists(diameap_sm), );
     1244
    12451245                free(diameap_sm);
    12461246                diameap_sm = NULL;
  • extensions/app_diameap/diameap_tls.c

    r874 r1151  
    396396        */
    397397        fprintf(stderr, "-------------End Dump EAP-TLS msg-------------\n");
     398       
     399        free(data);
    398400}
    399401
Note: See TracChangeset for help on using the changeset viewer.