Browse Source

cmScore.c : Added _cmScFreeSectList() to fix memory on free when CSV parse fails.

master
kevin 8 years ago
parent
commit
fdfe4d404a
1 changed files with 23 additions and 11 deletions
  1. 23
    11
      app/cmScore.c

+ 23
- 11
app/cmScore.c View File

361
   }
361
   }
362
 }
362
 }
363
 
363
 
364
+void _cmScFreeSectList( cmSc_t* p )
365
+{
366
+  
367
+  // release the section linked list
368
+  cmScSect_t* sp = p->sectList;
369
+  cmScSect_t* np = NULL;
370
+  while(sp!=NULL)
371
+  {
372
+    np = sp->link;
373
+    cmMemFree(sp);
374
+    sp = np;
375
+  }
376
+  
377
+  p->sectList = NULL;
378
+}
379
+
364
 void _cmScFreeSetList( cmScSet_t* setList )
380
 void _cmScFreeSetList( cmScSet_t* setList )
365
 {
381
 {
366
   cmScSet_t* tp = setList;
382
   cmScSet_t* tp = setList;
412
     cmMemFree(p->sets);
428
     cmMemFree(p->sets);
413
   }
429
   }
414
 
430
 
431
+  _cmScFreeSectList( p );
432
+
415
   _cmScFreeSetList(p->setList);
433
   _cmScFreeSetList(p->setList);
416
 
434
 
417
   _cmScFreeMarkList(p->markList);
435
   _cmScFreeMarkList(p->markList);
1119
 
1137
 
1120
 
1138
 
1121
 
1139
 
1122
-cmScRC_t _cmScProcSections( cmSc_t* p, cmScSect_t* sectList )
1140
+cmScRC_t _cmScProcSections( cmSc_t* p )
1123
 {
1141
 {
1124
   cmScRC_t rc = kOkScRC;
1142
   cmScRC_t rc = kOkScRC;
1143
+  cmScSect_t* sectList = p->sectList;
1125
   unsigned i;
1144
   unsigned i;
1126
 
1145
 
1127
   // count the sections
1146
   // count the sections
1166
     }
1185
     }
1167
   }
1186
   }
1168
 
1187
 
1169
-  // release the section linked list
1170
-  sp = sectList;
1171
-  cmScSect_t* np = NULL;
1172
-  while(sp!=NULL)
1173
-  {
1174
-    np = sp->link;
1175
-    cmMemFree(sp);
1176
-    sp = np;
1177
-  }
1178
 
1188
 
1189
+  _cmScFreeSectList(p);
1190
+  
1179
   //_cmScPrintSets("Sets",p->setList );
1191
   //_cmScPrintSets("Sets",p->setList );
1180
 
1192
 
1181
   _cmScProcSets(p);
1193
   _cmScProcSets(p);
1587
   if((rc = _cmScInitLocArray(p)) != kOkScRC )
1599
   if((rc = _cmScInitLocArray(p)) != kOkScRC )
1588
     goto errLabel;
1600
     goto errLabel;
1589
 
1601
 
1590
-  if((rc = _cmScProcSections(p,p->sectList)) != kOkScRC )
1602
+  if((rc = _cmScProcSections(p)) != kOkScRC )
1591
     goto errLabel;
1603
     goto errLabel;
1592
 
1604
 
1593
   if((rc = _cmScProcMarkers(p)) != kOkScRC )
1605
   if((rc = _cmScProcMarkers(p)) != kOkScRC )

Loading…
Cancel
Save