Permalink
Browse files

clientRefactor -- check bounds when removing fixmes

Summary:
when the size is longer than the length of the buffer,
truncate the size so that we grab until the end of the string.

truncation is totally silent and does not generate an error
or warning

Reviewed By: dabek

Differential Revision: D7014322

fbshipit-source-id: 1a48c811b00a7eb232c43a0864c9a81d27cc0e96
  • Loading branch information...
Greg Nisbet authored and hhvm-bot committed Apr 6, 2018
1 parent 42ec3f6 commit 5b9ed6ee8f9fcd7538074533d7f196c14eb81e11
Showing with 1 addition and 0 deletions.
  1. +1 −0 hphp/hack/src/client/clientRefactor.ml
@@ -47,6 +47,7 @@ let write_patches_to_buffer buf original_content patch_list =
let add_original_content j =
if j <= !i then () else
let size = (j - !i + 1) in
let size = min (-(!i) + String.length original_content) size in
let str_to_write = String.sub original_content !i size in
Buffer.add_string buf str_to_write;
i := !i + size

0 comments on commit 5b9ed6e

Please sign in to comment.