@@ -67,7 +67,7 @@ void taint_analysist::instrument(
67
67
{
68
68
const goto_programt::instructiont &instruction=*it;
69
69
70
- goto_programt tmp ;
70
+ goto_programt insert_before, insert_after ;
71
71
72
72
switch (instruction.type )
73
73
{
@@ -164,15 +164,15 @@ void taint_analysist::instrument(
164
164
code_set_may.op0 ()=where;
165
165
code_set_may.op1 ()=
166
166
address_of_exprt (string_constantt (rule.taint ));
167
- goto_programt::targett t=tmp .add_instruction ();
167
+ goto_programt::targett t=insert_after .add_instruction ();
168
168
t->make_other (code_set_may);
169
169
t->source_location =instruction.source_location ;
170
170
}
171
171
break ;
172
172
173
173
case taint_parse_treet::rulet::SINK:
174
174
{
175
- goto_programt::targett t=tmp .add_instruction ();
175
+ goto_programt::targett t=insert_before .add_instruction ();
176
176
binary_predicate_exprt get_may (" get_may" );
177
177
get_may.op0 ()=where;
178
178
get_may.op1 ()=address_of_exprt (string_constantt (rule.taint ));
@@ -191,7 +191,7 @@ void taint_analysist::instrument(
191
191
code_clear_may.op0 ()=where;
192
192
code_clear_may.op1 ()=
193
193
address_of_exprt (string_constantt (rule.taint ));
194
- goto_programt::targett t=tmp .add_instruction ();
194
+ goto_programt::targett t=insert_after .add_instruction ();
195
195
t->make_other (code_clear_may);
196
196
t->source_location =instruction.source_location ;
197
197
}
@@ -208,11 +208,17 @@ void taint_analysist::instrument(
208
208
}
209
209
}
210
210
211
- if (!tmp .empty ())
211
+ if (!insert_before .empty ())
212
212
{
213
- goto_programt::targett next=it;
214
- next++;
215
- goto_function.body .destructive_insert (next, tmp);
213
+ goto_function.body .insert_before_swap (it, insert_before);
214
+ // advance until we get back to the call
215
+ while (!it->is_function_call ()) ++it;
216
+ }
217
+
218
+ if (!insert_after.empty ())
219
+ {
220
+ goto_function.body .destructive_insert (
221
+ std::next (it), insert_after);
216
222
}
217
223
}
218
224
}
0 commit comments