Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mullvad Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Mullvad Browser
Commits
0367d148
Commit
0367d148
authored
25 years ago
by
akkana%netscape.com
Browse files
Options
Downloads
Patches
Plain Diff
Fix crash on second paste -- don't free our own memory, rely on transferable to do it
parent
9f7e2955
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
widget/src/gtk/nsClipboard.cpp
+14
-15
14 additions, 15 deletions
widget/src/gtk/nsClipboard.cpp
with
14 additions
and
15 deletions
widget/src/gtk/nsClipboard.cpp
+
14
−
15
View file @
0367d148
...
...
@@ -269,7 +269,8 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
printf
(
" GetNativeClipboardData: Transferable is null!
\n
"
);
return
NS_ERROR_FAILURE
;
}
// Dunno why we need to do this, copying the win32 code ...
nsCOMPtr
<
nsIGenericTransferable
>
genericTrans
=
do_QueryInterface
(
aTransferable
);
if
(
!
genericTrans
)
return
rv
;
...
...
@@ -328,16 +329,12 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
// for the callback saying that the data have been transferred.
//
// Set a flag saying that we're blocking waiting for the callback:
mBlocking
=
PR_TRUE
;
#ifdef DEBUG_CLIPBOARD
printf
(
"Waiting for the callback
\n
"
);
#endif
/* DEBUG_CLIPBOARD */
if
(
mSelectionData
.
data
!=
nsnull
)
g_free
(
mSelectionData
.
data
);
mSelectionData
.
data
=
nsnull
;
mSelectionData
.
length
=
0
;
mBlocking
=
PR_TRUE
;
// Now we need to wait until the callback comes in ...
// i is in case we get a runaway (yuck).
for
(
int
i
=
0
;
mBlocking
==
PR_TRUE
&&
i
<
10000
;
++
i
)
...
...
@@ -345,16 +342,14 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
gtk_main_iteration_do
(
TRUE
);
}
mBlocking
=
PR_FALSE
;
if
(
!
mSelectionData
.
data
)
return
NS_ERROR_NOT_AVAILABLE
;
#ifdef DEBUG_CLIPBOARD
printf
(
"Got the callback: '%s', %d
\n
"
,
mSelectionData
.
data
,
mSelectionData
.
length
);
#endif
/* DEBUG_CLIPBOARD */
// We're back from the callback, no longer blocking:
mBlocking
=
PR_FALSE
;
//
// Now we have data in mSelectionData.data.
// We just have to copy it to the transferable.
...
...
@@ -364,10 +359,12 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
genericTrans
->
SetTransferData
(
dataFlavor
,
mSelectionData
.
data
,
mSelectionData
.
length
);
// Can't free the selection data -- the transferable doesn't make a copy.
// Can't free the selection data -- the transferable just saves a pointer.
// But the transferable is responsible for freeing it, so we have to
// consider it freed now:
//g_free(mSelectionData.data);
//
mSelectionData.data = nsnull;
//
mSelectionData.length = 0;
mSelectionData
.
data
=
nsnull
;
mSelectionData
.
length
=
0
;
return
NS_OK
;
}
...
...
@@ -423,6 +420,8 @@ nsClipboard::SelectionReceiver (GtkWidget *aWidget,
mSelectionData
.
data
=
g_new
(
guchar
,
aSelectionData
->
length
+
1
);
memcpy
(
mSelectionData
.
data
,
aSelectionData
->
data
,
aSelectionData
->
length
);
// Null terminate in case anyone cares,
// and so we can print the string for debugging:
mSelectionData
.
data
[
aSelectionData
->
length
]
=
'\0'
;
mSelectionData
.
length
=
aSelectionData
->
length
;
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment