Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 15618cc

Browse files
committed
Ensure referent data doesn't go out of scope for StringRef/Twine
- Fixes #7
1 parent f0cf1ce commit 15618cc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

wpiutil/src/type_casters/wpi_stringref_type_caster.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ struct type_caster<wpi::StringRef>
3232

3333
// this assumes that the stringref won't be retained after the function call
3434
value = wpi::StringRef(data, size);
35+
36+
// src must be valid as long as this loader is valid
37+
loader_life_support::add_patient(src);
3538
return true;
3639
}
3740

wpiutil/src/type_casters/wpi_twine_type_caster.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ struct type_caster<wpi::Twine>
3939

4040
// this assumes that the stringref won't be retained after the function call
4141
ref = wpi::StringRef(data, size);
42+
43+
// src must be valid as long as this loader is valid
44+
loader_life_support::add_patient(src);
4245
return true;
4346
}
4447

0 commit comments

Comments
 (0)