qt: Fix use of dangling pointer in QApplication
* qt/main.cpp (main): Use a new variable for argc that stays valid. -- The QApplication constructor takes argc as a reference and the referenced integer has to stay alive for at least as long as the QApplication. GnuPG-Bug-Id: T4658 Based on a Patch from: Fabian Vogt <fvogt@suse.com> Thanks! (cherry picked from commit 0e2e53c8987d6f236aaef515eb005e8e86397fbc) Gbp-Pq: Name 0006-qt-Fix-use-of-dangling-pointer-in-QApplication.patch
This commit is contained in:
parent
143a14363c
commit
25129ff4ae
12
qt/main.cpp
12
qt/main.cpp
|
@ -312,6 +312,7 @@ main(int argc, char *argv[])
|
|||
pinentry_init("pinentry-qt");
|
||||
|
||||
QApplication *app = NULL;
|
||||
int new_argc = 0;
|
||||
|
||||
#ifdef FALLBACK_CURSES
|
||||
if (!pinentry_have_display(argc, argv)) {
|
||||
|
@ -351,8 +352,15 @@ main(int argc, char *argv[])
|
|||
p += strlen(argv[i]) + 1;
|
||||
}
|
||||
|
||||
i = argc;
|
||||
app = new QApplication(i, new_argv);
|
||||
/* Note: QApplication uses int &argc so argc has to be valid
|
||||
* for the full lifetime of the application.
|
||||
*
|
||||
* As Qt might modify argc / argv we use copies here so that
|
||||
* we do not loose options that are handled in both. e.g. display.
|
||||
*/
|
||||
new_argc = argc;
|
||||
Q_ASSERT (new_argc);
|
||||
app = new QApplication(new_argc, new_argv);
|
||||
app->setWindowIcon(QIcon(QLatin1String(":/document-encrypt.png")));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue