diff options
author | Mateusz Polrola <mateuszx.potrola at intel.com> | 2016-03-31 20:15:27 +0900 |
---|---|---|
committer | Wataru Natsume <wataru_natsume@xddp.denso.co.jp> | 2016-03-31 20:21:39 +0900 |
commit | 36a56e98fb208683888c8c1bf9fcf49008610dfd (patch) | |
tree | 000e1fa19a9fbff0b1596ad5bc83716403d95ad1 | |
parent | f887969606d881d9aea02893b68d4ec35ece8d78 (diff) | |
download | wayland-ivi-extension-36a56e98fb208683888c8c1bf9fcf49008610dfd.tar.gz |
ivi-controller: fixed string copy in controller_screen_screenshot
With earlier implementation memory for NULL byte of l->filename string
was not being allocated by malloc (strlen is returning length of string
without NULL terminating byte) which may result in some random
characters appended in filename string.
Now strdup is begin used for string copy instead of malloc/strcpy.
Signed-off-by: Mateusz Polrola <mateuszx.potrola at intel.com>
-rw-r--r-- | weston-ivi-shell/src/ivi-controller-impl.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-controller-impl.c index 5fa78aa..15e677e 100644 --- a/weston-ivi-shell/src/ivi-controller-impl.c +++ b/weston-ivi-shell/src/ivi-controller-impl.c @@ -917,7 +917,7 @@ controller_screen_screenshot(struct wl_client *client, return; } - l->filename = malloc(strlen(filename)); + l->filename = strdup(filename); if(l->filename == NULL) { fprintf(stderr, "fails to allocate memory\n"); free(l); @@ -925,7 +925,6 @@ controller_screen_screenshot(struct wl_client *client, } output = ivi_extension_screen_get_output(iviscrn->shell, iviscrn->layout_screen); - strcpy(l->filename, filename); l->listener.notify = controller_screenshot_notify; wl_signal_add(&output->frame_signal, &l->listener); output->disable_planes++; |