Fossil SCM

Fix binary blob detection in the new break_into_lines() algorithm.

mistachkin 2016-10-03 19:22 trunk
Commit dacc2bad82d0073a133c77616f3f8f336ec7a4b9
1 file changed +9 -1
+9 -1
--- src/diff.c
+++ src/diff.c
@@ -157,11 +157,11 @@
157157
return a;
158158
}
159159
i = 0;
160160
do{
161161
zNL = strchr(z,'\n');
162
- if( zNL==0 ) zNL = z+strlen(z);
162
+ if( zNL==0 ) zNL = z+n;
163163
nn = (int)(zNL - z);
164164
if( nn>LENGTH_MASK ){
165165
fossil_free(a);
166166
return 0;
167167
}
@@ -177,10 +177,14 @@
177177
}
178178
if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){
179179
int numws = 0;
180180
while( s<k && fossil_isspace(z[s]) ){ s++; }
181181
for(h=0, x=s; x<k; x++){
182
+ if( z[x]==0 ){
183
+ fossil_free(a);
184
+ return 0;
185
+ }
182186
if( fossil_isspace(z[x]) ){
183187
++numws;
184188
}else{
185189
h += z[x];
186190
h *= 0x9e3779b1;
@@ -187,10 +191,14 @@
187191
}
188192
}
189193
k -= numws;
190194
}else{
191195
for(h=0, x=s; x<k; x++){
196
+ if( z[x]==0 ){
197
+ fossil_free(a);
198
+ return 0;
199
+ }
192200
h += z[x];
193201
h *= 0x9e3779b1;
194202
}
195203
}
196204
a[i].indent = s;
197205
--- src/diff.c
+++ src/diff.c
@@ -157,11 +157,11 @@
157 return a;
158 }
159 i = 0;
160 do{
161 zNL = strchr(z,'\n');
162 if( zNL==0 ) zNL = z+strlen(z);
163 nn = (int)(zNL - z);
164 if( nn>LENGTH_MASK ){
165 fossil_free(a);
166 return 0;
167 }
@@ -177,10 +177,14 @@
177 }
178 if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){
179 int numws = 0;
180 while( s<k && fossil_isspace(z[s]) ){ s++; }
181 for(h=0, x=s; x<k; x++){
 
 
 
 
182 if( fossil_isspace(z[x]) ){
183 ++numws;
184 }else{
185 h += z[x];
186 h *= 0x9e3779b1;
@@ -187,10 +191,14 @@
187 }
188 }
189 k -= numws;
190 }else{
191 for(h=0, x=s; x<k; x++){
 
 
 
 
192 h += z[x];
193 h *= 0x9e3779b1;
194 }
195 }
196 a[i].indent = s;
197
--- src/diff.c
+++ src/diff.c
@@ -157,11 +157,11 @@
157 return a;
158 }
159 i = 0;
160 do{
161 zNL = strchr(z,'\n');
162 if( zNL==0 ) zNL = z+n;
163 nn = (int)(zNL - z);
164 if( nn>LENGTH_MASK ){
165 fossil_free(a);
166 return 0;
167 }
@@ -177,10 +177,14 @@
177 }
178 if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){
179 int numws = 0;
180 while( s<k && fossil_isspace(z[s]) ){ s++; }
181 for(h=0, x=s; x<k; x++){
182 if( z[x]==0 ){
183 fossil_free(a);
184 return 0;
185 }
186 if( fossil_isspace(z[x]) ){
187 ++numws;
188 }else{
189 h += z[x];
190 h *= 0x9e3779b1;
@@ -187,10 +191,14 @@
191 }
192 }
193 k -= numws;
194 }else{
195 for(h=0, x=s; x<k; x++){
196 if( z[x]==0 ){
197 fossil_free(a);
198 return 0;
199 }
200 h += z[x];
201 h *= 0x9e3779b1;
202 }
203 }
204 a[i].indent = s;
205

Keyboard Shortcuts

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