diff options
Diffstat (limited to 'cpp/src/Ice/Initialize.cpp')
-rw-r--r-- | cpp/src/Ice/Initialize.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index a246214986c..a2d31e93784 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -50,8 +50,10 @@ Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[]) { // // Shift all elements in argv which are present in args to the - // beginning of argv. + // beginning of argv. We record the original value of argc so + // that we can know later if we've shifted the array. // + const int argcOrig = argc; int i = 0; while(i < argc) { @@ -71,8 +73,10 @@ Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[]) // // Make sure that argv[argc] == 0, the ISO C++ standard requires this. + // We can only do this if we've shifted the array, otherwise argv[argc] + // may point to an invalid address. // - if(argv) + if(argv && argcOrig != argc) { argv[argc] = 0; } |