Fossil SCM
Fix binary blob detection in the new break_into_lines() algorithm.
Commit
dacc2bad82d0073a133c77616f3f8f336ec7a4b9
Parent
903af996f51b84d…
1 file changed
+9
-1
+9
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -157,11 +157,11 @@ | ||
| 157 | 157 | return a; |
| 158 | 158 | } |
| 159 | 159 | i = 0; |
| 160 | 160 | do{ |
| 161 | 161 | zNL = strchr(z,'\n'); |
| 162 | - if( zNL==0 ) zNL = z+strlen(z); | |
| 162 | + if( zNL==0 ) zNL = z+n; | |
| 163 | 163 | nn = (int)(zNL - z); |
| 164 | 164 | if( nn>LENGTH_MASK ){ |
| 165 | 165 | fossil_free(a); |
| 166 | 166 | return 0; |
| 167 | 167 | } |
| @@ -177,10 +177,14 @@ | ||
| 177 | 177 | } |
| 178 | 178 | if( (diffFlags & DIFF_IGNORE_ALLWS)==DIFF_IGNORE_ALLWS ){ |
| 179 | 179 | int numws = 0; |
| 180 | 180 | while( s<k && fossil_isspace(z[s]) ){ s++; } |
| 181 | 181 | for(h=0, x=s; x<k; x++){ |
| 182 | + if( z[x]==0 ){ | |
| 183 | + fossil_free(a); | |
| 184 | + return 0; | |
| 185 | + } | |
| 182 | 186 | if( fossil_isspace(z[x]) ){ |
| 183 | 187 | ++numws; |
| 184 | 188 | }else{ |
| 185 | 189 | h += z[x]; |
| 186 | 190 | h *= 0x9e3779b1; |
| @@ -187,10 +191,14 @@ | ||
| 187 | 191 | } |
| 188 | 192 | } |
| 189 | 193 | k -= numws; |
| 190 | 194 | }else{ |
| 191 | 195 | for(h=0, x=s; x<k; x++){ |
| 196 | + if( z[x]==0 ){ | |
| 197 | + fossil_free(a); | |
| 198 | + return 0; | |
| 199 | + } | |
| 192 | 200 | h += z[x]; |
| 193 | 201 | h *= 0x9e3779b1; |
| 194 | 202 | } |
| 195 | 203 | } |
| 196 | 204 | a[i].indent = s; |
| 197 | 205 |
| --- 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 |