aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2012-09-16 23:17:31 +0900
committerChris E Ferron <chris.e.ferron@linux.intel.com>2012-09-17 08:15:27 -0700
commit7efd0813b7ec9fe844a4177059eeebae4575390a (patch)
treecb3eba8f0582c039e8189340c8062875cecc0ce5
parentbb194d09d18e7a7000b2ca743b943c74fb982e31 (diff)
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>
-rw-r--r--src/perf/perf.cpp5
1 files changed, 5 insertions, 0 deletions
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 @@ void perf_event::set_event_name(const char *event_name)
if (name)
free(name);
name = strdup(event_name);
+ if (!name) {
+ fprintf(stderr, "failed to allocate event name\n");
+ return;
+ }
+
char *c;
c = strchr(name, ':');