diff --git a/libs/gtkmm2ext/motionfeedback.cc b/libs/gtkmm2ext/motionfeedback.cc index 44fb3e5f47..bd0fd1cd73 100644 --- a/libs/gtkmm2ext/motionfeedback.cc +++ b/libs/gtkmm2ext/motionfeedback.cc @@ -468,14 +468,18 @@ Glib::RefPtr MotionFeedback::render_pixbuf (int size) { Glib::RefPtr pixbuf; - char path[32]; + char *path; int fd; + GError *error = NULL; - snprintf (path, sizeof (path), "/tmp/mfimg%dXXXXXX", size); - - if ((fd = mkstemp (path)) < 0) { + fd = g_file_open_tmp ("mfimgXXXXXX", &path, &error); + close (fd); + + if(error) { + g_critical("failed to open a temporary file for writing: %s.", error->message); + g_error_free (error); return pixbuf; - } + } GdkColor col2 = {0,0,0,0}; GdkColor col3 = {0,0,0,0}; @@ -522,6 +526,8 @@ MotionFeedback::render_pixbuf (int size) unlink (path); + g_free(path); + return pixbuf; }