* Re: [Powertop] [PATCH 2/2] perf: Check return value of strdup
@ 2012-09-17 15:21 Chris Ferron
0 siblings, 0 replies; 3+ messages in thread
From: Chris Ferron @ 2012-09-17 15:21 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 739 bytes --]
On 09/16/2012 07:17 AM, Namhyung Kim wrote:
> The strdup() can return NULL so that the result should be checked.
>
> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---
> src/perf/perf.cpp | 5 +++++
> 1 file changed, 5 insertions(+)
>
> 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, ':');
Your patch as been merged.
Thank You
-C
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Powertop] [PATCH 2/2] perf: Check return value of strdup
@ 2012-09-16 22:48 Sergey Senozhatsky
0 siblings, 0 replies; 3+ messages in thread
From: Sergey Senozhatsky @ 2012-09-16 22:48 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 729 bytes --]
On (09/16/12 23:17), Namhyung Kim wrote:
> The strdup() can return NULL so that the result should be checked.
>
> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---
looks good to me, thank you.
-ss
> src/perf/perf.cpp | 5 +++++
> 1 file changed, 5 insertions(+)
>
> 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, ':');
^ permalink raw reply [flat|nested] 3+ messages in thread* [Powertop] [PATCH 2/2] perf: Check return value of strdup
@ 2012-09-16 14:17 Namhyung Kim
0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2012-09-16 14:17 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 615 bytes --]
The strdup() can return NULL so that the result should be checked.
Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
src/perf/perf.cpp | 5 +++++
1 file changed, 5 insertions(+)
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, ':');
--
1.7.9.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-17 15:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 15:21 [Powertop] [PATCH 2/2] perf: Check return value of strdup Chris Ferron
-- strict thread matches above, loose matches on Subject: below --
2012-09-16 22:48 Sergey Senozhatsky
2012-09-16 14:17 Namhyung Kim
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.