perf: Check return value of strdup

The strdup() can return NULL so that the result should be checked.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
diff --git a/src/perf/perf.cpp b/src/perf/perf.cpp
index c8ba7a8..35b4017 100644
--- a/src/perf/perf.cpp
+++ b/src/perf/perf.cpp
@@ -145,6 +145,11 @@
 	if (name)
 		free(name);
 	name = strdup(event_name);
+	if (!name) {
+		fprintf(stderr, "failed to allocate event name\n");
+		return;
+	}
+
 	char *c;
 
 	c = strchr(name, ':');