aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorScott J. Goldman <scottjg@github.com>2012-08-31 22:47:19 -0700
committerScott J. Goldman <scottjg@github.com>2012-08-31 22:47:19 -0700
commite415a1351bf3e7eff0a33574400fa89c0941d9bf (patch)
tree19500b0f8c2a160436176fe23dacbe738a482628 /lib
parent6ec907a915bf3d18d8f7debb58e9e859cb9de16c (diff)
When testing if a blob is indexable, check size first
Otherwise, charlock_holmes will allocate another large binary buffer for testing the encoding, which is a problem if the binary blob is many hundreds of MB large. It'll just fail and crash ruby.
Diffstat (limited to 'lib')
-rw-r--r--lib/linguist/blob_helper.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb
index b2d72f1..fbbaff9 100644
--- a/lib/linguist/blob_helper.rb
+++ b/lib/linguist/blob_helper.rb
@@ -250,7 +250,9 @@ module Linguist
#
# Return true or false
def indexable?
- if binary?
+ if size > 100 * 1024
+ false
+ elsif binary?
false
elsif extname == '.txt'
true
@@ -260,8 +262,6 @@ module Linguist
false
elsif generated?
false
- elsif size > 100 * 1024
- false
else
true
end