summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2013-11-21 09:25:56 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2013-11-21 09:25:56 +0100
commitab82c45a5da8a2fdcea530bb8ba942f31f8e9880 (patch)
tree29d256e1b0e707f070c7a962c312176c11909a5a
parent46ee3c3226e69dad43998574c63eccf7e1fe3f59 (diff)
wl_screenshot: Fix eina_file_mkstemp usage.
In my previous commit I did not took into account that ein_file_mkstemp does not alter the given filename. This is different from mkstemp and I missed that. We now ask for the new filename and use it instead.
-rw-r--r--src/modules/wl_screenshot/e_mod_main.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/modules/wl_screenshot/e_mod_main.c b/src/modules/wl_screenshot/e_mod_main.c
index a4a3c9ab9..eadc89ab4 100644
--- a/src/modules/wl_screenshot/e_mod_main.c
+++ b/src/modules/wl_screenshot/e_mod_main.c
@@ -219,15 +219,16 @@ static struct wl_buffer *
219_create_shm_buffer(struct wl_shm *_shm, int width, int height, void **data_out) 219_create_shm_buffer(struct wl_shm *_shm, int width, int height, void **data_out)
220{ 220{
221 char filename[] = "wayland-shm-XXXXXX"; 221 char filename[] = "wayland-shm-XXXXXX";
222 Eina_Tmpstr *tmpfile = NULL;
222 struct wl_shm_pool *pool; 223 struct wl_shm_pool *pool;
223 struct wl_buffer *buffer; 224 struct wl_buffer *buffer;
224 int fd, size, stride; 225 int fd, size, stride;
225 void *data; 226 void *data;
226 227
227 fd = eina_file_mkstemp(filename, NULL); 228 fd = eina_file_mkstemp(filename, &tmpfile);
228 if (fd < 0) 229 if (fd < 0)
229 { 230 {
230 fprintf(stderr, "open %s failed: %m\n", filename); 231 fprintf(stderr, "open %s failed: %m\n", tmpfile);
231 return NULL; 232 return NULL;
232 } 233 }
233 234
@@ -241,7 +242,8 @@ _create_shm_buffer(struct wl_shm *_shm, int width, int height, void **data_out)
241 } 242 }
242 243
243 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 244 data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
244 unlink(filename); 245 unlink(tmpfile);
246 eina_tmpstr_del(tmpfile);
245 247
246 if (data == MAP_FAILED) 248 if (data == MAP_FAILED)
247 { 249 {