Fossil SCM

Fix harmless memory leaks.

drh 2024-12-18 11:39 trunk
Commit 37ae94b365a9f32191b41862b989a9ac805fae9fe2c63d7c66bc9e5257971a15
+1 -1
--- src/db.c
+++ src/db.c
@@ -2105,11 +2105,11 @@
21052105
sqlite3 *, char **, const sqlite3_api_routines *
21062106
);
21072107
sqlite3_appendvfs_init(0,0,0);
21082108
g.zVfsName = "apndvfs";
21092109
}
2110
- blob_zero(&bNameCheck);
2110
+ blob_reset(&bNameCheck);
21112111
rc = sqlite3_open_v2(
21122112
zDbName, &db,
21132113
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
21142114
g.zVfsName
21152115
);
21162116
--- src/db.c
+++ src/db.c
@@ -2105,11 +2105,11 @@
2105 sqlite3 *, char **, const sqlite3_api_routines *
2106 );
2107 sqlite3_appendvfs_init(0,0,0);
2108 g.zVfsName = "apndvfs";
2109 }
2110 blob_zero(&bNameCheck);
2111 rc = sqlite3_open_v2(
2112 zDbName, &db,
2113 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
2114 g.zVfsName
2115 );
2116
--- src/db.c
+++ src/db.c
@@ -2105,11 +2105,11 @@
2105 sqlite3 *, char **, const sqlite3_api_routines *
2106 );
2107 sqlite3_appendvfs_init(0,0,0);
2108 g.zVfsName = "apndvfs";
2109 }
2110 blob_reset(&bNameCheck);
2111 rc = sqlite3_open_v2(
2112 zDbName, &db,
2113 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
2114 g.zVfsName
2115 );
2116
+8 -1
--- src/doc.c
+++ src/doc.c
@@ -788,11 +788,11 @@
788788
){
789789
Blob title;
790790
int isPopup = P("popup")!=0;
791791
blob_init(&title,0,0);
792792
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
793
- Blob tail;
793
+ Blob tail = BLOB_INITIALIZER;
794794
style_adunit_config(ADUNIT_RIGHT_OK);
795795
if( wiki_find_title(pBody, &title, &tail) ){
796796
if( !isPopup ) style_header("%s", blob_str(&title));
797797
wiki_convert(&tail, 0, WIKI_BUTTONS);
798798
}else{
@@ -801,10 +801,11 @@
801801
}
802802
if( !isPopup ){
803803
document_emit_js();
804804
style_finish_page();
805805
}
806
+ blob_reset(&tail);
806807
}else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
807808
Blob tail = BLOB_INITIALIZER;
808809
markdown_to_html(pBody, &title, &tail);
809810
if( !isPopup ){
810811
if( blob_size(&title)>0 ){
@@ -816,10 +817,11 @@
816817
convert_href_and_output(&tail);
817818
if( !isPopup ){
818819
document_emit_js();
819820
style_finish_page();
820821
}
822
+ blob_reset(&tail);
821823
}else if( fossil_strcmp(zMime, "text/plain")==0 ){
822824
style_header("%s", zDefaultTitle);
823825
@ <blockquote><pre>
824826
@ %h(blob_str(pBody))
825827
@ </pre></blockquote>
@@ -949,10 +951,11 @@
949951
950952
login_check_credentials();
951953
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
952954
style_set_current_feature("doc");
953955
blob_init(&title, 0, 0);
956
+ blob_init(&filebody, 0, 0);
954957
zDfltTitle = isUV ? "" : "Documentation";
955958
db_begin_transaction();
956959
while( rid==0 && (++nMiss)<=count(azSuffix) ){
957960
zName = P("name");
958961
if( isUV ){
@@ -1059,10 +1062,12 @@
10591062
}
10601063
cgi_check_for_malice();
10611064
document_render(&filebody, zMime, zDfltTitle, zName);
10621065
if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
10631066
db_end_transaction(0);
1067
+ blob_reset(&title);
1068
+ blob_reset(&filebody);
10641069
return;
10651070
10661071
/* Jump here when unable to locate the document */
10671072
doc_not_found:
10681073
db_end_transaction(0);
@@ -1075,10 +1080,12 @@
10751080
@ <p>Document %h(zOrigName) not found
10761081
if( fossil_strcmp(zCheckin,"ckout")!=0 ){
10771082
@ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
10781083
}
10791084
style_finish_page();
1085
+ blob_reset(&title);
1086
+ blob_reset(&filebody);
10801087
return;
10811088
}
10821089
10831090
/*
10841091
** The default logo.
10851092
--- src/doc.c
+++ src/doc.c
@@ -788,11 +788,11 @@
788 ){
789 Blob title;
790 int isPopup = P("popup")!=0;
791 blob_init(&title,0,0);
792 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
793 Blob tail;
794 style_adunit_config(ADUNIT_RIGHT_OK);
795 if( wiki_find_title(pBody, &title, &tail) ){
796 if( !isPopup ) style_header("%s", blob_str(&title));
797 wiki_convert(&tail, 0, WIKI_BUTTONS);
798 }else{
@@ -801,10 +801,11 @@
801 }
802 if( !isPopup ){
803 document_emit_js();
804 style_finish_page();
805 }
 
806 }else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
807 Blob tail = BLOB_INITIALIZER;
808 markdown_to_html(pBody, &title, &tail);
809 if( !isPopup ){
810 if( blob_size(&title)>0 ){
@@ -816,10 +817,11 @@
816 convert_href_and_output(&tail);
817 if( !isPopup ){
818 document_emit_js();
819 style_finish_page();
820 }
 
821 }else if( fossil_strcmp(zMime, "text/plain")==0 ){
822 style_header("%s", zDefaultTitle);
823 @ <blockquote><pre>
824 @ %h(blob_str(pBody))
825 @ </pre></blockquote>
@@ -949,10 +951,11 @@
949
950 login_check_credentials();
951 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
952 style_set_current_feature("doc");
953 blob_init(&title, 0, 0);
 
954 zDfltTitle = isUV ? "" : "Documentation";
955 db_begin_transaction();
956 while( rid==0 && (++nMiss)<=count(azSuffix) ){
957 zName = P("name");
958 if( isUV ){
@@ -1059,10 +1062,12 @@
1059 }
1060 cgi_check_for_malice();
1061 document_render(&filebody, zMime, zDfltTitle, zName);
1062 if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
1063 db_end_transaction(0);
 
 
1064 return;
1065
1066 /* Jump here when unable to locate the document */
1067 doc_not_found:
1068 db_end_transaction(0);
@@ -1075,10 +1080,12 @@
1075 @ <p>Document %h(zOrigName) not found
1076 if( fossil_strcmp(zCheckin,"ckout")!=0 ){
1077 @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
1078 }
1079 style_finish_page();
 
 
1080 return;
1081 }
1082
1083 /*
1084 ** The default logo.
1085
--- src/doc.c
+++ src/doc.c
@@ -788,11 +788,11 @@
788 ){
789 Blob title;
790 int isPopup = P("popup")!=0;
791 blob_init(&title,0,0);
792 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
793 Blob tail = BLOB_INITIALIZER;
794 style_adunit_config(ADUNIT_RIGHT_OK);
795 if( wiki_find_title(pBody, &title, &tail) ){
796 if( !isPopup ) style_header("%s", blob_str(&title));
797 wiki_convert(&tail, 0, WIKI_BUTTONS);
798 }else{
@@ -801,10 +801,11 @@
801 }
802 if( !isPopup ){
803 document_emit_js();
804 style_finish_page();
805 }
806 blob_reset(&tail);
807 }else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
808 Blob tail = BLOB_INITIALIZER;
809 markdown_to_html(pBody, &title, &tail);
810 if( !isPopup ){
811 if( blob_size(&title)>0 ){
@@ -816,10 +817,11 @@
817 convert_href_and_output(&tail);
818 if( !isPopup ){
819 document_emit_js();
820 style_finish_page();
821 }
822 blob_reset(&tail);
823 }else if( fossil_strcmp(zMime, "text/plain")==0 ){
824 style_header("%s", zDefaultTitle);
825 @ <blockquote><pre>
826 @ %h(blob_str(pBody))
827 @ </pre></blockquote>
@@ -949,10 +951,11 @@
951
952 login_check_credentials();
953 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
954 style_set_current_feature("doc");
955 blob_init(&title, 0, 0);
956 blob_init(&filebody, 0, 0);
957 zDfltTitle = isUV ? "" : "Documentation";
958 db_begin_transaction();
959 while( rid==0 && (++nMiss)<=count(azSuffix) ){
960 zName = P("name");
961 if( isUV ){
@@ -1059,10 +1062,12 @@
1062 }
1063 cgi_check_for_malice();
1064 document_render(&filebody, zMime, zDfltTitle, zName);
1065 if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
1066 db_end_transaction(0);
1067 blob_reset(&title);
1068 blob_reset(&filebody);
1069 return;
1070
1071 /* Jump here when unable to locate the document */
1072 doc_not_found:
1073 db_end_transaction(0);
@@ -1075,10 +1080,12 @@
1080 @ <p>Document %h(zOrigName) not found
1081 if( fossil_strcmp(zCheckin,"ckout")!=0 ){
1082 @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
1083 }
1084 style_finish_page();
1085 blob_reset(&title);
1086 blob_reset(&filebody);
1087 return;
1088 }
1089
1090 /*
1091 ** The default logo.
1092
+1
--- src/info.c
+++ src/info.c
@@ -320,10 +320,11 @@
320320
|TIMELINE_NOSCROLL
321321
|TIMELINE_XMERGE
322322
|TIMELINE_CHPICK,
323323
0, 0, 0, rid, rid2, 0);
324324
db_finalize(&q);
325
+ blob_reset(&sql);
325326
}
326327
327328
328329
/*
329330
** Append the difference between artifacts to the output
330331
--- src/info.c
+++ src/info.c
@@ -320,10 +320,11 @@
320 |TIMELINE_NOSCROLL
321 |TIMELINE_XMERGE
322 |TIMELINE_CHPICK,
323 0, 0, 0, rid, rid2, 0);
324 db_finalize(&q);
 
325 }
326
327
328 /*
329 ** Append the difference between artifacts to the output
330
--- src/info.c
+++ src/info.c
@@ -320,10 +320,11 @@
320 |TIMELINE_NOSCROLL
321 |TIMELINE_XMERGE
322 |TIMELINE_CHPICK,
323 0, 0, 0, rid, rid2, 0);
324 db_finalize(&q);
325 blob_reset(&sql);
326 }
327
328
329 /*
330 ** Append the difference between artifacts to the output
331
--- src/style.c
+++ src/style.c
@@ -821,10 +821,11 @@
821821
if( g.perm.Debug && P("showqp") ){
822822
@ <div class="debug">
823823
cgi_print_all(0, 0, 0);
824824
@ </div>
825825
}
826
+ fossil_free(zTitle);
826827
}
827828
828829
#if INTERFACE
829830
/* Allowed parameters for style_adunit() */
830831
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
@@ -1300,10 +1301,11 @@
13001301
Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
13011302
Th_Store("home", g.zTop);
13021303
image_url_var("logo");
13031304
image_url_var("background");
13041305
Th_Render(blob_str(&css));
1306
+ blob_reset(&css);
13051307
13061308
/* Tell CGI that the content returned by this page is considered cacheable */
13071309
g.isConst = 1;
13081310
}
13091311
13101312
--- src/style.c
+++ src/style.c
@@ -821,10 +821,11 @@
821 if( g.perm.Debug && P("showqp") ){
822 @ <div class="debug">
823 cgi_print_all(0, 0, 0);
824 @ </div>
825 }
 
826 }
827
828 #if INTERFACE
829 /* Allowed parameters for style_adunit() */
830 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
@@ -1300,10 +1301,11 @@
1300 Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
1301 Th_Store("home", g.zTop);
1302 image_url_var("logo");
1303 image_url_var("background");
1304 Th_Render(blob_str(&css));
 
1305
1306 /* Tell CGI that the content returned by this page is considered cacheable */
1307 g.isConst = 1;
1308 }
1309
1310
--- src/style.c
+++ src/style.c
@@ -821,10 +821,11 @@
821 if( g.perm.Debug && P("showqp") ){
822 @ <div class="debug">
823 cgi_print_all(0, 0, 0);
824 @ </div>
825 }
826 fossil_free(zTitle);
827 }
828
829 #if INTERFACE
830 /* Allowed parameters for style_adunit() */
831 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
@@ -1300,10 +1301,11 @@
1301 Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
1302 Th_Store("home", g.zTop);
1303 image_url_var("logo");
1304 image_url_var("background");
1305 Th_Render(blob_str(&css));
1306 blob_reset(&css);
1307
1308 /* Tell CGI that the content returned by this page is considered cacheable */
1309 g.isConst = 1;
1310 }
1311
1312
--- src/timeline.c
+++ src/timeline.c
@@ -3077,10 +3077,12 @@
30773077
if( zOlderButton ){
30783078
@ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
30793079
@ &nbsp;&darr;</a>
30803080
}
30813081
document_emit_js(/*handles pikchrs rendered above*/);
3082
+ blob_reset(&sql);
3083
+ blob_reset(&desc);
30823084
style_finish_page();
30833085
}
30843086
30853087
/*
30863088
** Translate a timeline entry into the printable format by
30873089
--- src/timeline.c
+++ src/timeline.c
@@ -3077,10 +3077,12 @@
3077 if( zOlderButton ){
3078 @ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
3079 @ &nbsp;&darr;</a>
3080 }
3081 document_emit_js(/*handles pikchrs rendered above*/);
 
 
3082 style_finish_page();
3083 }
3084
3085 /*
3086 ** Translate a timeline entry into the printable format by
3087
--- src/timeline.c
+++ src/timeline.c
@@ -3077,10 +3077,12 @@
3077 if( zOlderButton ){
3078 @ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
3079 @ &nbsp;&darr;</a>
3080 }
3081 document_emit_js(/*handles pikchrs rendered above*/);
3082 blob_reset(&sql);
3083 blob_reset(&desc);
3084 style_finish_page();
3085 }
3086
3087 /*
3088 ** Translate a timeline entry into the printable format by
3089

Keyboard Shortcuts

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