Fossil SCM

Several memleak fixes reported via https://fossil-scm.org/forum/forumpost/205b004d8a. In a branch so the OP can test them in his setup.

stephan 2019-12-19 18:54 trunk
Commit 4566da665ddb4b5f321def7fd67ffc7fbf616d8666adee6e5bc5db5654fecf5b
--- src/import.c
+++ src/import.c
@@ -336,10 +336,12 @@
336336
**
337337
** This behavior seems like a bug in git-fast-export, but it is easier
338338
** to work around the problem than to fix git-fast-export.
339339
*/
340340
if( gg.tagCommit && gg.zDate && gg.zUser && gg.zFrom ){
341
+ record.nUsed = 0
342
+ /*in case fast_insert_comment() did not indirectly blob_reset() it */;
341343
blob_appendf(&record, "D %s\n", gg.zDate);
342344
blob_appendf(&record, "T +sym-%F%F%F %s\n", gimport.zBranchPre, gg.zBranch,
343345
gimport.zBranchSuf, gg.zPrevCheckin);
344346
blob_appendf(&record, "U %F\n", gg.zUser);
345347
md5sum_blob(&record, &cksum);
346348
--- src/import.c
+++ src/import.c
@@ -336,10 +336,12 @@
336 **
337 ** This behavior seems like a bug in git-fast-export, but it is easier
338 ** to work around the problem than to fix git-fast-export.
339 */
340 if( gg.tagCommit && gg.zDate && gg.zUser && gg.zFrom ){
 
 
341 blob_appendf(&record, "D %s\n", gg.zDate);
342 blob_appendf(&record, "T +sym-%F%F%F %s\n", gimport.zBranchPre, gg.zBranch,
343 gimport.zBranchSuf, gg.zPrevCheckin);
344 blob_appendf(&record, "U %F\n", gg.zUser);
345 md5sum_blob(&record, &cksum);
346
--- src/import.c
+++ src/import.c
@@ -336,10 +336,12 @@
336 **
337 ** This behavior seems like a bug in git-fast-export, but it is easier
338 ** to work around the problem than to fix git-fast-export.
339 */
340 if( gg.tagCommit && gg.zDate && gg.zUser && gg.zFrom ){
341 record.nUsed = 0
342 /*in case fast_insert_comment() did not indirectly blob_reset() it */;
343 blob_appendf(&record, "D %s\n", gg.zDate);
344 blob_appendf(&record, "T +sym-%F%F%F %s\n", gimport.zBranchPre, gg.zBranch,
345 gimport.zBranchSuf, gg.zPrevCheckin);
346 blob_appendf(&record, "U %F\n", gg.zUser);
347 md5sum_blob(&record, &cksum);
348
+3 -2
--- src/manifest.c
+++ src/manifest.c
@@ -2087,12 +2087,13 @@
20872087
if( (p = manifest_cache_find(rid))!=0 ){
20882088
blob_reset(pContent);
20892089
}else if( (p = manifest_parse(pContent, rid, 0))==0 ){
20902090
assert( blob_is_reset(pContent) || pContent==0 );
20912091
if( (flags & MC_NO_ERRORS)==0 ){
2092
- fossil_error(1, "syntax error in manifest [%S]",
2093
- db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid));
2092
+ char * zErrUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid);
2093
+ fossil_error(1, "syntax error in manifest [%S]", zErrUuid);
2094
+ fossil_free(zErrUuid);
20942095
}
20952096
return 0;
20962097
}
20972098
if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
20982099
manifest_destroy(p);
20992100
--- src/manifest.c
+++ src/manifest.c
@@ -2087,12 +2087,13 @@
2087 if( (p = manifest_cache_find(rid))!=0 ){
2088 blob_reset(pContent);
2089 }else if( (p = manifest_parse(pContent, rid, 0))==0 ){
2090 assert( blob_is_reset(pContent) || pContent==0 );
2091 if( (flags & MC_NO_ERRORS)==0 ){
2092 fossil_error(1, "syntax error in manifest [%S]",
2093 db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid));
 
2094 }
2095 return 0;
2096 }
2097 if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
2098 manifest_destroy(p);
2099
--- src/manifest.c
+++ src/manifest.c
@@ -2087,12 +2087,13 @@
2087 if( (p = manifest_cache_find(rid))!=0 ){
2088 blob_reset(pContent);
2089 }else if( (p = manifest_parse(pContent, rid, 0))==0 ){
2090 assert( blob_is_reset(pContent) || pContent==0 );
2091 if( (flags & MC_NO_ERRORS)==0 ){
2092 char * zErrUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid);
2093 fossil_error(1, "syntax error in manifest [%S]", zErrUuid);
2094 fossil_free(zErrUuid);
2095 }
2096 return 0;
2097 }
2098 if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
2099 manifest_destroy(p);
2100
+2 -1
--- src/tkt.c
+++ src/tkt.c
@@ -364,11 +364,11 @@
364364
365365
/*
366366
** Recreate the TICKET and TICKETCHNG tables.
367367
*/
368368
void ticket_create_table(int separateConnection){
369
- const char *zSql;
369
+ char *zSql;
370370
371371
db_multi_exec(
372372
"DROP TABLE IF EXISTS ticket;"
373373
"DROP TABLE IF EXISTS ticketchng;"
374374
);
@@ -377,10 +377,11 @@
377377
if( db_transaction_nesting_depth() ) db_end_transaction(0);
378378
db_init_database(g.zRepositoryName, zSql, 0);
379379
}else{
380380
db_multi_exec("%s", zSql/*safe-for-%s*/);
381381
}
382
+ fossil_free(zSql);
382383
}
383384
384385
/*
385386
** Repopulate the TICKET and TICKETCHNG tables from scratch using all
386387
** available ticket artifacts.
387388
--- src/tkt.c
+++ src/tkt.c
@@ -364,11 +364,11 @@
364
365 /*
366 ** Recreate the TICKET and TICKETCHNG tables.
367 */
368 void ticket_create_table(int separateConnection){
369 const char *zSql;
370
371 db_multi_exec(
372 "DROP TABLE IF EXISTS ticket;"
373 "DROP TABLE IF EXISTS ticketchng;"
374 );
@@ -377,10 +377,11 @@
377 if( db_transaction_nesting_depth() ) db_end_transaction(0);
378 db_init_database(g.zRepositoryName, zSql, 0);
379 }else{
380 db_multi_exec("%s", zSql/*safe-for-%s*/);
381 }
 
382 }
383
384 /*
385 ** Repopulate the TICKET and TICKETCHNG tables from scratch using all
386 ** available ticket artifacts.
387
--- src/tkt.c
+++ src/tkt.c
@@ -364,11 +364,11 @@
364
365 /*
366 ** Recreate the TICKET and TICKETCHNG tables.
367 */
368 void ticket_create_table(int separateConnection){
369 char *zSql;
370
371 db_multi_exec(
372 "DROP TABLE IF EXISTS ticket;"
373 "DROP TABLE IF EXISTS ticketchng;"
374 );
@@ -377,10 +377,11 @@
377 if( db_transaction_nesting_depth() ) db_end_transaction(0);
378 db_init_database(g.zRepositoryName, zSql, 0);
379 }else{
380 db_multi_exec("%s", zSql/*safe-for-%s*/);
381 }
382 fossil_free(zSql);
383 }
384
385 /*
386 ** Repopulate the TICKET and TICKETCHNG tables from scratch using all
387 ** available ticket artifacts.
388
+3 -2
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -96,13 +96,14 @@
9696
@ );
9797
@ CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);
9898
;
9999
100100
/*
101
-** Return the ticket table definition
101
+** Return the ticket table definition in heap-allocated
102
+** memory owned by the caller.
102103
*/
103
-const char *ticket_table_schema(void){
104
+char *ticket_table_schema(void){
104105
return db_get("ticket-table", zDefaultTicketTable);
105106
}
106107
107108
/*
108109
** Common implementation for the ticket setup editor pages.
109110
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -96,13 +96,14 @@
96 @ );
97 @ CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);
98 ;
99
100 /*
101 ** Return the ticket table definition
 
102 */
103 const char *ticket_table_schema(void){
104 return db_get("ticket-table", zDefaultTicketTable);
105 }
106
107 /*
108 ** Common implementation for the ticket setup editor pages.
109
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -96,13 +96,14 @@
96 @ );
97 @ CREATE INDEX ticketchng_idx1 ON ticketchng(tkt_id, tkt_mtime);
98 ;
99
100 /*
101 ** Return the ticket table definition in heap-allocated
102 ** memory owned by the caller.
103 */
104 char *ticket_table_schema(void){
105 return db_get("ticket-table", zDefaultTicketTable);
106 }
107
108 /*
109 ** Common implementation for the ticket setup editor pages.
110

Keyboard Shortcuts

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