Changeset d3b33d5


Ignore:
Timestamp:
Sep 9, 2024, 11:43:43 AM (2 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
a7efc96
Parents:
02101a4
Message:

fix dangling reference after delete

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/StatementNode.cpp

    r02101a4 rd3b33d5  
    1111// Created On       : Sat May 16 14:59:41 2015
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Aug 11 11:44:15 2023
    14 // Update Count     : 429
     13// Last Modified On : Mon Sep  9 11:28:07 2024
     14// Update Count     : 430
    1515//
    1616
     
    208208
    209209ast::Stmt * build_for( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ ) {
    210         std::vector<ast::ptr<ast::Stmt>> astinit;                                               // maybe empty
     210        std::vector<ast::ptr<ast::Stmt>> astinit;                       // maybe empty
    211211        buildMoveList( forctl->init, astinit );
    212212
    213213        if ( forctl->range_over ) {
    214214                ast::Expr * range_over = maybeMoveBuild( forctl->range_over );
     215                auto kind = forctl->kind;                                               // save before delete, used in return
    215216                delete forctl;
    216217                return new ast::ForStmt( location,
    217218                        std::move( astinit ),
    218                         range_over, forctl->kind == OperKinds::LEThan,
     219                        range_over, kind == OperKinds::LEThan,
    219220                        buildMoveSingle( stmt ),
    220221                        buildMoveOptional( else_ )
Note: See TracChangeset for help on using the changeset viewer.