Fossil SCM

Always close opendir() objects if and only if successfully opened. Ticket [6f8614716702180a0]

drh 2011-02-16 19:19 trunk
Commit f73ed21d3b6e58b54066d5312bacd0c936dc4b77
+2 -2
--- src/add.c
+++ src/add.c
@@ -188,12 +188,12 @@
188188
}else if( file_isfile(zPath) ){
189189
db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath);
190190
}
191191
blob_resize(&path, origSize);
192192
}
193
+ closedir(d);
193194
}
194
- closedir(d);
195195
blob_reset(&path);
196196
}
197197
198198
/*
199199
** Add all content of a directory.
@@ -321,12 +321,12 @@
321321
}
322322
blob_reset(&pathname);
323323
}
324324
blob_resize(&path, origSize);
325325
}
326
+ closedir(d);
326327
}
327
- closedir(d);
328328
blob_reset(&path);
329329
}
330330
331331
/*
332332
** COMMAND: rm
333333
--- src/add.c
+++ src/add.c
@@ -188,12 +188,12 @@
188 }else if( file_isfile(zPath) ){
189 db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath);
190 }
191 blob_resize(&path, origSize);
192 }
 
193 }
194 closedir(d);
195 blob_reset(&path);
196 }
197
198 /*
199 ** Add all content of a directory.
@@ -321,12 +321,12 @@
321 }
322 blob_reset(&pathname);
323 }
324 blob_resize(&path, origSize);
325 }
 
326 }
327 closedir(d);
328 blob_reset(&path);
329 }
330
331 /*
332 ** COMMAND: rm
333
--- src/add.c
+++ src/add.c
@@ -188,12 +188,12 @@
188 }else if( file_isfile(zPath) ){
189 db_multi_exec("INSERT INTO sfile VALUES(%Q)", zPath);
190 }
191 blob_resize(&path, origSize);
192 }
193 closedir(d);
194 }
 
195 blob_reset(&path);
196 }
197
198 /*
199 ** Add all content of a directory.
@@ -321,12 +321,12 @@
321 }
322 blob_reset(&pathname);
323 }
324 blob_resize(&path, origSize);
325 }
326 closedir(d);
327 }
 
328 blob_reset(&path);
329 }
330
331 /*
332 ** COMMAND: rm
333
--- src/rebuild.c
+++ src/rebuild.c
@@ -602,10 +602,11 @@
602602
blob_reset(&aContent);
603603
free(zSubpath);
604604
printf("\r%d", ++nFileRead);
605605
fflush(stdout);
606606
}
607
+ closedir(d);
607608
}else {
608609
fossil_panic("encountered error %d while trying to open \"%s\".",
609610
errno, g.argv[3]);
610611
}
611612
}
612613
--- src/rebuild.c
+++ src/rebuild.c
@@ -602,10 +602,11 @@
602 blob_reset(&aContent);
603 free(zSubpath);
604 printf("\r%d", ++nFileRead);
605 fflush(stdout);
606 }
 
607 }else {
608 fossil_panic("encountered error %d while trying to open \"%s\".",
609 errno, g.argv[3]);
610 }
611 }
612
--- src/rebuild.c
+++ src/rebuild.c
@@ -602,10 +602,11 @@
602 blob_reset(&aContent);
603 free(zSubpath);
604 printf("\r%d", ++nFileRead);
605 fflush(stdout);
606 }
607 closedir(d);
608 }else {
609 fossil_panic("encountered error %d while trying to open \"%s\".",
610 errno, g.argv[3]);
611 }
612 }
613
+1 -1
--- src/vfile.c
+++ src/vfile.c
@@ -310,12 +310,12 @@
310310
}else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
311311
db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
312312
}
313313
blob_resize(pPath, origSize);
314314
}
315
+ closedir(d);
315316
}
316
- closedir(d);
317317
}
318318
319319
/*
320320
** Compute an aggregate MD5 checksum over the disk image of every
321321
** file in vid. The file names are part of the checksum. The resulting
322322
--- src/vfile.c
+++ src/vfile.c
@@ -310,12 +310,12 @@
310 }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
311 db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
312 }
313 blob_resize(pPath, origSize);
314 }
 
315 }
316 closedir(d);
317 }
318
319 /*
320 ** Compute an aggregate MD5 checksum over the disk image of every
321 ** file in vid. The file names are part of the checksum. The resulting
322
--- src/vfile.c
+++ src/vfile.c
@@ -310,12 +310,12 @@
310 }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
311 db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
312 }
313 blob_resize(pPath, origSize);
314 }
315 closedir(d);
316 }
 
317 }
318
319 /*
320 ** Compute an aggregate MD5 checksum over the disk image of every
321 ** file in vid. The file names are part of the checksum. The resulting
322

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button