Skip to content

Commit

Permalink
[astgen] Fix two use-after-frees.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoecarver committed Oct 31, 2022
1 parent 47b29b6 commit 06d6c92
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/AST/CASTBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,19 @@ void *SwiftIdentifierExpr_create(void *ctx, BridgedIdentifier base, void *loc) {
void *SwiftStringLiteralExpr_create(void *ctx, const uint8_t *_Nullable string,
long len, void *TokenLoc) {
ASTContext &Context = *static_cast<ASTContext *>(ctx);
return new (Context) StringLiteralExpr(
StringRef{reinterpret_cast<const char *>(string), size_t(len)},
getSourceLocFromPointer(TokenLoc));
auto stringRef = Context.AllocateCopy(
StringRef{reinterpret_cast<const char *>(string), size_t(len)});
return new (Context)
StringLiteralExpr(stringRef, getSourceLocFromPointer(TokenLoc));
}

void *SwiftIntegerLiteralExpr_create(void *ctx, const uint8_t *_Nullable string,
long len, void *TokenLoc) {
ASTContext &Context = *static_cast<ASTContext *>(ctx);
return new (Context) IntegerLiteralExpr(
StringRef{reinterpret_cast<const char *>(string), size_t(len)},
getSourceLocFromPointer(TokenLoc));
auto stringRef = Context.AllocateCopy(
StringRef{reinterpret_cast<const char *>(string), size_t(len)});
return new (Context)
IntegerLiteralExpr(stringRef, getSourceLocFromPointer(TokenLoc));
}

void *SwiftBooleanLiteralExpr_create(void *ctx, bool value, void *TokenLoc) {
Expand Down

0 comments on commit 06d6c92

Please sign in to comment.