Fossil SCM

If a file to be diffed contains an 0x00 character, consider it to be binary and do not attempt the diff.

drh 2016-10-04 01:53 trunk
Commit 334ab15270b814ac259b5787298f1e6b80edd81f
1 file changed +1
+1
--- src/diff.c
+++ src/diff.c
@@ -147,10 +147,11 @@
147147
/* Count the number of lines in the input file. Include the last line
148148
** in the count even if it lacks the \n terminator
149149
*/
150150
for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){}
151151
if( z2[0]!=0 ) nLine++;
152
+ if( n!=(int)(z2-z) ) return 0;
152153
153154
a = fossil_malloc( sizeof(a[0])*nLine );
154155
memset(a, 0, sizeof(a[0])*nLine);
155156
if( nLine==0 ){
156157
*pnLine = 0;
157158
--- src/diff.c
+++ src/diff.c
@@ -147,10 +147,11 @@
147 /* Count the number of lines in the input file. Include the last line
148 ** in the count even if it lacks the \n terminator
149 */
150 for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){}
151 if( z2[0]!=0 ) nLine++;
 
152
153 a = fossil_malloc( sizeof(a[0])*nLine );
154 memset(a, 0, sizeof(a[0])*nLine);
155 if( nLine==0 ){
156 *pnLine = 0;
157
--- src/diff.c
+++ src/diff.c
@@ -147,10 +147,11 @@
147 /* Count the number of lines in the input file. Include the last line
148 ** in the count even if it lacks the \n terminator
149 */
150 for(nLine=0, z2=z; (zNL = strchr(z2,'\n'))!=0; z2=zNL+1, nLine++){}
151 if( z2[0]!=0 ) nLine++;
152 if( n!=(int)(z2-z) ) return 0;
153
154 a = fossil_malloc( sizeof(a[0])*nLine );
155 memset(a, 0, sizeof(a[0])*nLine);
156 if( nLine==0 ){
157 *pnLine = 0;
158

Keyboard Shortcuts

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