char **argv = new char*[4 + appArgc];
char **argv = new char*[5 + appArgc];
ApplyUpdate(nsIFile *appDir, nsIFile *updateDir, nsILocalFile *statusFile,            int appArgc, char **appArgv){  // Steps:  //  - mark update as 'applying'  //  - copy updater into update dir  //  - run updater w/ app dir as the current working dir  nsCOMPtr<nsIFile> updater;  if (!CopyUpdaterIntoUpdateDir(appDir, updateDir, updater)) {    LOG(("failed copying updater\n"));    return;  }  // We need to use the value returned from XRE_GetBinaryPath when attempting  // to restart the running application.  nsCOMPtr<nsILocalFile> appFile;  XRE_GetBinaryPath(appArgv[0], getter_AddRefs(appFile));  if (!appFile)    return;  nsCAutoString appFilePath;  nsresult rv = appFile->GetNativePath(appFilePath);  if (NS_FAILED(rv))    return;    nsCAutoString updaterPath;  rv = updater->GetNativePath(updaterPath);  if (NS_FAILED(rv))    return;  nsCAutoString appDirPath;#if defined(XP_MACOSX)  // On Mac OSX, we need to apply the update to the Contents directory  // which is the parent of the parent of the appDir.  {    nsCOMPtr<nsIFile> parentDir1, parentDir2;    rv = appDir->GetParent(getter_AddRefs(parentDir1));    if (NS_FAILED(rv))      return;    rv = parentDir1->GetParent(getter_AddRefs(parentDir2));    if (NS_FAILED(rv))      return;    rv = parentDir2->GetNativePath(appDirPath);  }#else  rv = appDir->GetNativePath(appDirPath);#endif  if (NS_FAILED(rv))    return;  nsCAutoString updateDirPath;  rv = updateDir->GetNativePath(updateDirPath);  if (NS_FAILED(rv))    return;  if (!SetStatus(statusFile, "applying")) {    LOG(("failed setting status to 'applying'\n"));    return;  }  // Construct the PID argument for this process.  If we are using execv, then  // we pass "0" which is then ignored by the updater.#if defined(USE_EXECV)  NS_NAMED_LITERAL_CSTRING(pid, "0");#else  nsCAutoString pid;  pid.AppendInt((PRInt32)# if defined(XP_WIN)    GetCurrentProcessId()# else    getpid()# endif    );#endif  char **argv = new char*[4 + appArgc];  if (!argv)    return;  argv[0] = (char*) updaterPath.get();  argv[1] = (char*) updateDirPath.get();  argv[2] = (char*) pid.get();  if (appArgc) {    argv[3] = (char*) appFilePath.get();    for (int i = 1; i < appArgc; ++i)      argv[3 + i] = appArgv[i];  }  argv[3 + appArgc] = nsnull;  LOG(("spawning updater process [%s]\n", updaterPath.get()));#if defined(USE_EXECV)  chdir(appDirPath.get());  execv(updaterPath.get(), argv);#elif defined(XP_WIN)  _chdir(appDirPath.get());  if (!WinLaunchChild(updaterPath.get(), appArgc + 3, argv))    return;  _exit(0);#else  PRStatus status;  PRProcessAttr *attr;    attr = PR_NewProcessAttr();  if (!attr)    goto end;  status = PR_ProcessAttrSetCurrentDirectory(attr, appDirPath.get());  if (status != PR_SUCCESS)    goto end;  PR_CreateProcessDetached(updaterPath.get(), argv, nsnull, attr);  exit(0);end:  PR_DestroyProcessAttr(attr);   delete[] argv;#endif}