Przeglądaj źródła

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

master
kevin 8 lat temu
rodzic
commit
fdfe4d404a
1 zmienionych plików z 23 dodań i 11 usunięć
  1. 23
    11
      app/cmScore.c

+ 23
- 11
app/cmScore.c Wyświetl plik

@@ -361,6 +361,22 @@ void _cmScFreeMarkList( cmScMark_t* markList )
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 380
 void _cmScFreeSetList( cmScSet_t* setList )
365 381
 {
366 382
   cmScSet_t* tp = setList;
@@ -412,6 +428,8 @@ cmScRC_t _cmScFinalize( cmSc_t* p )
412 428
     cmMemFree(p->sets);
413 429
   }
414 430
 
431
+  _cmScFreeSectList( p );
432
+
415 433
   _cmScFreeSetList(p->setList);
416 434
 
417 435
   _cmScFreeMarkList(p->markList);
@@ -1119,9 +1137,10 @@ cmScRC_t _cmScProcSets( cmSc_t* p )
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 1142
   cmScRC_t rc = kOkScRC;
1143
+  cmScSect_t* sectList = p->sectList;
1125 1144
   unsigned i;
1126 1145
 
1127 1146
   // count the sections
@@ -1166,16 +1185,9 @@ cmScRC_t _cmScProcSections( cmSc_t* p, cmScSect_t* sectList )
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 1191
   //_cmScPrintSets("Sets",p->setList );
1180 1192
 
1181 1193
   _cmScProcSets(p);
@@ -1587,7 +1599,7 @@ cmScRC_t cmScoreInitialize( cmCtx_t* ctx, cmScH_t* hp, const cmChar_t* fn, doubl
1587 1599
   if((rc = _cmScInitLocArray(p)) != kOkScRC )
1588 1600
     goto errLabel;
1589 1601
 
1590
-  if((rc = _cmScProcSections(p,p->sectList)) != kOkScRC )
1602
+  if((rc = _cmScProcSections(p)) != kOkScRC )
1591 1603
     goto errLabel;
1592 1604
 
1593 1605
   if((rc = _cmScProcMarkers(p)) != kOkScRC )

Ładowanie…
Anuluj
Zapisz