diff --git a/src/utils/utils.php b/src/utils/utils.php
index 5e5f305..d7f8482 100644
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -770,6 +770,16 @@ function phutil_split_lines($corpus, $retain_endings = true) {
return array('');
}
+ $lines = substr_count($corpus, "\n");
+ $limit = 1024;
+ if ($lines > $limit) {
+ throw new Exception(
+ pht(
+ 'Huge input! Found %s lines, hoped for %s.',
+ new PhutilNumber($lines),
+ new Phutilnumber($limit)));
+ }
+
// Split on "\r\n" or "\n".
if ($retain_endings) {
$lines = preg_split('/(?<=\n)/', $corpus);