summaryrefslogtreecommitdiffstats
path: root/win/tkWinDialog.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-11-13 13:51:01 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-11-13 13:51:01 (GMT)
commit387810da124d6770e1928f7b0dc8c3a09ed74f8f (patch)
tree7632a2c75a05dc0165cc20b25cac651bed222e70 /win/tkWinDialog.c
parentc0a48c6acf8c6820e9cd64da88384b0ced42f8e3 (diff)
downloadtk-387810da124d6770e1928f7b0dc8c3a09ed74f8f.zip
tk-387810da124d6770e1928f7b0dc8c3a09ed74f8f.tar.gz
tk-387810da124d6770e1928f7b0dc8c3a09ed74f8f.tar.bz2
Fix [d43a10ce2fed950e00890049f3c273f2cdd12583|d43a10ce2f]: tk_getOpenFile crashes when passed a bad -typevariable.
Diffstat (limited to 'win/tkWinDialog.c')
-rw-r--r--win/tkWinDialog.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index c90d05a..69dcb06 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -1009,10 +1009,28 @@ Tk_GetSaveFileObjCmd(
*/
static void CleanupOFNOptions(OFNOpts *optsPtr)
{
+ if (optsPtr->extObj) {
+ Tcl_DecrRefCount(optsPtr->extObj);
+ optsPtr->extObj = NULL;
+ }
+ if (optsPtr->titleObj) {
+ Tcl_DecrRefCount(optsPtr->titleObj);
+ optsPtr->titleObj = NULL;
+ }
+ if (optsPtr->filterObj) {
+ Tcl_DecrRefCount(optsPtr->filterObj);
+ optsPtr->filterObj = NULL;
+ }
+ if (optsPtr->typeVariableObj) {
+ Tcl_DecrRefCount(optsPtr->typeVariableObj);
+ optsPtr->typeVariableObj = NULL;
+ }
+ if (optsPtr->initialTypeObj) {
+ Tcl_DecrRefCount(optsPtr->initialTypeObj);
+ optsPtr->initialTypeObj = NULL;
+ }
Tcl_DStringFree(&optsPtr->utfDirString);
}
-
-
/*
*----------------------------------------------------------------------
@@ -1124,9 +1142,21 @@ ParseOFNOptions(
string = Tcl_GetString(valuePtr);
switch (options[index].value) {
case FILE_DEFAULT:
+ if (valuePtr) {
+ Tcl_IncrRefCount(valuePtr);
+ }
+ if (optsPtr->extObj) {
+ Tcl_DecrRefCount(optsPtr->extObj);
+ }
optsPtr->extObj = valuePtr;
break;
case FILE_TYPES:
+ if (valuePtr) {
+ Tcl_IncrRefCount(valuePtr);
+ }
+ if (optsPtr->filterObj) {
+ Tcl_DecrRefCount(optsPtr->filterObj);
+ }
optsPtr->filterObj = valuePtr;
break;
case FILE_INITDIR:
@@ -1150,12 +1180,30 @@ ParseOFNOptions(
goto error_return;
break;
case FILE_TITLE:
+ if (valuePtr) {
+ Tcl_IncrRefCount(valuePtr);
+ }
+ if (optsPtr->titleObj) {
+ Tcl_DecrRefCount(optsPtr->titleObj);
+ }
optsPtr->titleObj = valuePtr;
break;
case FILE_TYPEVARIABLE:
+ if (valuePtr) {
+ Tcl_IncrRefCount(valuePtr);
+ }
+ if (optsPtr->typeVariableObj) {
+ Tcl_DecrRefCount(optsPtr->typeVariableObj);
+ }
optsPtr->typeVariableObj = valuePtr;
+ if (optsPtr->initialTypeObj) {
+ Tcl_DecrRefCount(optsPtr->initialTypeObj);
+ }
optsPtr->initialTypeObj = Tcl_ObjGetVar2(interp, valuePtr,
NULL, TCL_GLOBAL_ONLY);
+ if (optsPtr->initialTypeObj) {
+ Tcl_IncrRefCount(optsPtr->initialTypeObj);
+ }
break;
case FILE_MULTIPLE:
if (Tcl_GetBooleanFromObj(interp, valuePtr,