Skip to content

Commit

Permalink
do not leak in case of error
Browse files Browse the repository at this point in the history
  • Loading branch information
borisbat committed Jul 9, 2021
1 parent 47d6cdb commit 48495ac
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions daslib/sort_boost.das
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,18 @@ class QsortMacro : AstCallMacro
if expr.arguments[1]._type.baseType != Type tBlock
macro_error(prog,expr.at,"expecting 2nd argument to be block(<a,b:auto(TT)>:bool))")
return [[ExpressionPtr]]
var call <- new [[ExprCall() name:="sort", at=expr.at]]
if expr.arguments[0]._type.dim.length != 0 || expr.arguments[0]._type.baseType==Type tArray
var call <- new [[ExprCall() name:="sort", at=expr.at]]
emplace_new(call.arguments) <| clone_expression(expr.arguments[0])
emplace_new(call.arguments) <| clone_expression(expr.arguments[1])
return <- call
elif expr.arguments[0]._type.baseType==Type tHandle
var call <- new [[ExprCall() name:="sort", at=expr.at]]
var tsa <- new [[ExprCall() name:="temp_sort_array", at=expr.at]]
emplace_new(tsa.arguments) <| clone_expression(expr.arguments[0])
tsa.genFlags |= ExprGenFlags alwaysSafe
emplace(call.arguments,tsa)
emplace_new(call.arguments,clone_expression(expr.arguments[1]))
emplace_new(call.arguments) <| clone_expression(expr.arguments[1])
return <- call
else
macro_error(prog,expr.at,"can only qsort [], array, or handled vector")
Expand Down

0 comments on commit 48495ac

Please sign in to comment.