Skip to content

Commit

Permalink
Use String.sub alternatives found by semgrep
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Jan 24, 2024
1 parent f1daea0 commit fe4b6b1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cdomain/value/cdomains/addressDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ struct
let compute_substring s1 s2 =
try
let i = Str.search_forward (Str.regexp_string s2) s1 0 in
Some (String.sub s1 i (String.length s1 - i))
Some (Str.string_after s1 i)
with Not_found -> None in

(* if any of the input address sets contains an element that isn't a StrPtr, return top *)
Expand Down
2 changes: 1 addition & 1 deletion src/cdomain/value/cdomains/stringDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let to_n_c_string n x =
else if n < 0 then
None
else
Some (String.sub x 0 n)
Some (Str.first_chars x n)
| None -> None

let to_string_length x =
Expand Down
2 changes: 1 addition & 1 deletion src/cdomains/apron/affineEqualityDomain.apron.ml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ struct
let res = (String.concat "" @@ Array.to_list @@ Array.map dim_to_str vars)
^ (const_to_str arr.(Array.length arr - 1)) ^ "=0" in
if String.starts_with res "+" then
String.sub res 1 (String.length res - 1)
Str.string_after res 1
else
res
in
Expand Down
2 changes: 1 addition & 1 deletion src/config/gobConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct
let rec split' i =
if i<l then begin
if xs.[i]=c1 || xs.[i]=c2 then
(String.sub xs 0 i, String.sub xs i (l-i))
(Str.first_chars xs i, Str.string_after xs i)
else
split' (i+1)
end else
Expand Down

0 comments on commit fe4b6b1

Please sign in to comment.