All of lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/3] tests/testdisplay: fix heap overflow
@ 2019-03-20 11:15 Simon Ser
  2019-03-20 11:15 ` [igt-dev] [PATCH i-g-t 2/3] meson: add -Wno-missing-braces Simon Ser
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Simon Ser @ 2019-03-20 11:15 UTC (permalink / raw)
  To: igt-dev

Also simplify the code by using dirname(3).

Signed-off-by: Simon Ser <simon.ser@intel.com>
---
 tests/testdisplay.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index b3657264..2b26ed1b 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -51,6 +51,7 @@
 #include <cairo.h>
 #include <errno.h>
 #include <getopt.h>
+#include <libgen.h>
 #include <math.h>
 #include <stdint.h>
 #include <stdbool.h>
@@ -563,24 +564,14 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,
 	return TRUE;
 }
 
-static void enter_exec_path( char **argv )
+static void enter_exec_path(char **argv)
 {
-	char *exec_path = NULL;
-	char *pos = NULL;
-	short len_path = 0;
+	char *exec_path;
 	int ret;
 
-	len_path = strlen( argv[0] );
-	exec_path = (char*) malloc(len_path);
-
-	memcpy(exec_path, argv[0], len_path);
-	pos = strrchr(exec_path, '/');
-	if (pos != NULL)
-		*(pos+1) = '\0';
-
+	exec_path = dirname(argv[0]);
 	ret = chdir(exec_path);
 	igt_assert_eq(ret, 0);
-	free(exec_path);
 }
 
 static void restore_termio_mode(int sig)
-- 
2.21.0

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-03-20 13:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 11:15 [igt-dev] [PATCH i-g-t 1/3] tests/testdisplay: fix heap overflow Simon Ser
2019-03-20 11:15 ` [igt-dev] [PATCH i-g-t 2/3] meson: add -Wno-missing-braces Simon Ser
2019-03-20 11:15 ` [igt-dev] [PATCH i-g-t 3/3] runner/executor: refactor error handling Simon Ser
2019-03-20 11:18 ` [igt-dev] [PATCH i-g-t 1/3] tests/testdisplay: fix heap overflow Ser, Simon
2019-03-20 11:22 ` Chris Wilson
2019-03-20 11:29   ` Ser, Simon
2019-03-20 13:01 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.