Skip to content

Commit

Permalink
Merge pull request #5679 from hedaoyuan/inference
Browse files Browse the repository at this point in the history
Fix crashes due to multiple calls to paddle_init
  • Loading branch information
hedaoyuan committed Nov 16, 2017
2 parents 6cf7f1e + 6303d3b commit 08bc08d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions paddle/capi/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ static void initPaddle(int argc, char** argv) {

extern "C" {
paddle_error paddle_init(int argc, char** argv) {
static bool isInit = false;
if (isInit) return kPD_NO_ERROR;

std::vector<char*> realArgv;
realArgv.reserve(argc + 1);
realArgv.push_back(strdup(""));
Expand All @@ -37,6 +40,7 @@ paddle_error paddle_init(int argc, char** argv) {
}
initPaddle(argc + 1, realArgv.data());
free(realArgv[0]);
isInit = true;
return kPD_NO_ERROR;
}
}

0 comments on commit 08bc08d

Please sign in to comment.