Skip to content

Commit

Permalink
Place c_api_Path_CheckLicense below c_api_Output_SetInterface (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchphillipson authored Jun 12, 2024
1 parent cbb4b8a commit c6f655b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/C_API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,7 @@ function solve_mcp(
)
@assert length(z) == length(lb) == length(ub)
n = length(z)
if c_api_Path_CheckLicense(n, nnz) == 0
return MCP_LicenseError, nothing, nothing
elseif nnz > typemax(Cint)
if nnz > typemax(Cint)
return MCP_Error, nothing, nothing
elseif n == 0
return MCP_Solved, nothing, nothing
Expand All @@ -742,6 +740,11 @@ function solve_mcp(
# We shouldn't GC output_interface until we exit the GC.@preserve block.
gc_root[output_interface] = true
c_api_Output_SetInterface(output_interface)
# We need to call `c_api_Path_CheckLicense` _after_ setting the output
# interface because CheckLicense may try to print to the screen.
if c_api_Path_CheckLicense(n, nnz) == 0
return MCP_LicenseError, nothing, nothing
end
o = c_api_Options_Create()
# Options has a finalizer. We don't want that to run until we exit the
# GC.@preserve block.
Expand Down

0 comments on commit c6f655b

Please sign in to comment.