Skip to content

Commit 08bc08d

Browse files
authored
Merge pull request #5679 from hedaoyuan/inference
Fix crashes due to multiple calls to paddle_init
2 parents 6cf7f1e + 6303d3b commit 08bc08d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

paddle/capi/Main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ static void initPaddle(int argc, char** argv) {
2929

3030
extern "C" {
3131
paddle_error paddle_init(int argc, char** argv) {
32+
static bool isInit = false;
33+
if (isInit) return kPD_NO_ERROR;
34+
3235
std::vector<char*> realArgv;
3336
realArgv.reserve(argc + 1);
3437
realArgv.push_back(strdup(""));
@@ -37,6 +40,7 @@ paddle_error paddle_init(int argc, char** argv) {
3740
}
3841
initPaddle(argc + 1, realArgv.data());
3942
free(realArgv[0]);
43+
isInit = true;
4044
return kPD_NO_ERROR;
4145
}
4246
}

0 commit comments

Comments
 (0)