Fossil SCM

Avoid comparing a variable to NULL after the memory it is pointing to has been freed. This is harmless, as implemented, but it is technically undefined behavior in C. (This is a bug in the specification of the C language, imho.)

drh 2016-11-19 17:50 trunk
Commit 4e126233caf6ef3d439955af866254758802a0d0
1 file changed +1 -1
+1 -1
--- src/info.c
+++ src/info.c
@@ -69,11 +69,10 @@
6969
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
7070
rid
7171
);
7272
/* 01234567890123 */
7373
fossil_print("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
74
- free(zUuid);
7574
free(zDate);
7675
}
7776
if( zUuid && showComment ){
7877
zComment = db_text(0,
7978
"SELECT coalesce(ecomment,comment) || "
@@ -80,10 +79,11 @@
8079
" ' (user: ' || coalesce(euser,user,'?') || ')' "
8180
" FROM event WHERE objid=%d",
8281
rid
8382
);
8483
}
84
+ free(zUuid);
8585
if( showFamily ){
8686
db_prepare(&q, "SELECT uuid, pid, isprim FROM plink JOIN blob ON pid=rid "
8787
" WHERE cid=%d"
8888
" ORDER BY isprim DESC, mtime DESC /*sort*/", rid);
8989
while( db_step(&q)==SQLITE_ROW ){
9090
--- src/info.c
+++ src/info.c
@@ -69,11 +69,10 @@
69 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
70 rid
71 );
72 /* 01234567890123 */
73 fossil_print("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
74 free(zUuid);
75 free(zDate);
76 }
77 if( zUuid && showComment ){
78 zComment = db_text(0,
79 "SELECT coalesce(ecomment,comment) || "
@@ -80,10 +79,11 @@
80 " ' (user: ' || coalesce(euser,user,'?') || ')' "
81 " FROM event WHERE objid=%d",
82 rid
83 );
84 }
 
85 if( showFamily ){
86 db_prepare(&q, "SELECT uuid, pid, isprim FROM plink JOIN blob ON pid=rid "
87 " WHERE cid=%d"
88 " ORDER BY isprim DESC, mtime DESC /*sort*/", rid);
89 while( db_step(&q)==SQLITE_ROW ){
90
--- src/info.c
+++ src/info.c
@@ -69,11 +69,10 @@
69 "SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d",
70 rid
71 );
72 /* 01234567890123 */
73 fossil_print("%-13s %s %s\n", zUuidName, zUuid, zDate ? zDate : "");
 
74 free(zDate);
75 }
76 if( zUuid && showComment ){
77 zComment = db_text(0,
78 "SELECT coalesce(ecomment,comment) || "
@@ -80,10 +79,11 @@
79 " ' (user: ' || coalesce(euser,user,'?') || ')' "
80 " FROM event WHERE objid=%d",
81 rid
82 );
83 }
84 free(zUuid);
85 if( showFamily ){
86 db_prepare(&q, "SELECT uuid, pid, isprim FROM plink JOIN blob ON pid=rid "
87 " WHERE cid=%d"
88 " ORDER BY isprim DESC, mtime DESC /*sort*/", rid);
89 while( db_step(&q)==SQLITE_ROW ){
90

Keyboard Shortcuts

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