Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: tools/gtk_clipboard_dump/gtk_clipboard_dump.cc

Issue 14917015: Fix several memory leaks in gtk_clipboard_dump utility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
diff --git a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
index c96ee0083693da327190e572246883d8bf7be3a4..abaa40c9a0840ef9ebb73fe0085ceb41d69537d9 100644
--- a/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
+++ b/tools/gtk_clipboard_dump/gtk_clipboard_dump.cc
@@ -28,22 +28,33 @@ void PrintClipboardContents(GtkClipboard* clip) {
printf("%d available targets:\n---------------\n", num_targets);
+ gboolean target_omitted;
+ gchar* target_name;
Evan Stade 2013/05/09 04:46:06 no reason for these to be declared outside the for
for (int i = 0; i < num_targets; i++) {
- printf(" [format: %s", gdk_atom_name(targets[i]));
+ target_name = gdk_atom_name(targets[i]);
+ printf(" [format: %s", target_name);
GtkSelectionData* data = gtk_clipboard_wait_for_contents(clip, targets[i]);
if (!data) {
printf("]: NULL\n\n");
+ g_free(target_name);
Evan Stade 2013/05/09 04:46:06 just copy it into a std::string and free right awa
continue;
}
printf(" / length: %d / bits %d]: ", data->length, data->format);
- if (strstr(gdk_atom_name(targets[i]), "image")) {
+ if (strstr(target_name, "image")) {
printf("(image omitted)\n\n");
- continue;
- } else if (strstr(gdk_atom_name(targets[i]), "TIMESTAMP")) {
+ target_omitted = true;
+ } else if (strstr(target_name, "TIMESTAMP")) {
// TODO(estade): Print the time stamp in human readable format.
printf("(time omitted)\n\n");
+ target_omitted = true;
+ } else
Evan Stade 2013/05/09 04:46:06 curlies
+ target_omitted = false;
+
+ g_free(target_name);
+ if (target_omitted) {
+ gtk_selection_data_free(data);
continue;
}
@@ -53,6 +64,7 @@ void PrintClipboardContents(GtkClipboard* clip) {
printf("%c", (data->data[j] == 0 ? '_' : data->data[j]));
}
printf("\n\n");
+ gtk_selection_data_free(data);
}
if (num_targets <= 0) {
@@ -63,6 +75,7 @@ void PrintClipboardContents(GtkClipboard* clip) {
}
g_free(targets);
+ gtk_selection_data_free(target_data);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698