util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] xalloc: check for NULL before calling strdup
@ 2011-09-29 18:56 Dave Reisner
  2011-09-29 18:56 ` [PATCH 2/2] xalloc: fix whitespace to be consistent Dave Reisner
  2011-09-29 23:42 ` [PATCH 1/2] xalloc: check for NULL before calling strdup Karel Zak
  0 siblings, 2 replies; 4+ messages in thread
From: Dave Reisner @ 2011-09-29 18:56 UTC (permalink / raw)
  To: util-linux; +Cc: Dave Reisner

This fixes a segfault in mount (and possibly elsewhere) when invoked
without a -t parameter.

Broken in 7ef9fd7 when the common xalloc.h libs were introduced.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
 include/xalloc.h |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/xalloc.h b/include/xalloc.h
index 8c505be..bea7e31 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -51,9 +51,14 @@ void *xcalloc(const size_t nelems, const size_t size)
 
 static inline char *xstrdup(const char *str)
 {
-	char *ret = strdup(str);
+	char *ret;
 
-	if (!ret && str)
+	if (!str)
+		return NULL;
+
+	ret = strdup(str);
+
+	if (!ret)
 		err(XALLOC_EXIT_CODE, "cannot duplicate string");
 	return ret;
 }
-- 
1.7.6.4


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

* [PATCH 2/2] xalloc: fix whitespace to be consistent
  2011-09-29 18:56 [PATCH 1/2] xalloc: check for NULL before calling strdup Dave Reisner
@ 2011-09-29 18:56 ` Dave Reisner
  2011-09-29 23:42   ` Karel Zak
  2011-09-29 23:42 ` [PATCH 1/2] xalloc: check for NULL before calling strdup Karel Zak
  1 sibling, 1 reply; 4+ messages in thread
From: Dave Reisner @ 2011-09-29 18:56 UTC (permalink / raw)
  To: util-linux; +Cc: Dave Reisner

We use spaces for the rest of this file, so the random tabs within
xstrdup stand out.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
 include/xalloc.h |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/xalloc.h b/include/xalloc.h
index bea7e31..feeb114 100644
--- a/include/xalloc.h
+++ b/include/xalloc.h
@@ -51,16 +51,16 @@ void *xcalloc(const size_t nelems, const size_t size)
 
 static inline char *xstrdup(const char *str)
 {
-	char *ret;
+        char *ret;
 
-	if (!str)
-		return NULL;
+        if (!str)
+                return NULL;
 
-	ret = strdup(str);
+        ret = strdup(str);
 
-	if (!ret)
-		err(XALLOC_EXIT_CODE, "cannot duplicate string");
-	return ret;
+        if (!ret)
+                err(XALLOC_EXIT_CODE, "cannot duplicate string");
+        return ret;
 }
 
 #endif
-- 
1.7.6.4


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

* Re: [PATCH 1/2] xalloc: check for NULL before calling strdup
  2011-09-29 18:56 [PATCH 1/2] xalloc: check for NULL before calling strdup Dave Reisner
  2011-09-29 18:56 ` [PATCH 2/2] xalloc: fix whitespace to be consistent Dave Reisner
@ 2011-09-29 23:42 ` Karel Zak
  1 sibling, 0 replies; 4+ messages in thread
From: Karel Zak @ 2011-09-29 23:42 UTC (permalink / raw)
  To: Dave Reisner; +Cc: util-linux, Dave Reisner

On Thu, Sep 29, 2011 at 02:56:41PM -0400, Dave Reisner wrote:
>  include/xalloc.h |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)

 Applied, thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

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

* Re: [PATCH 2/2] xalloc: fix whitespace to be consistent
  2011-09-29 18:56 ` [PATCH 2/2] xalloc: fix whitespace to be consistent Dave Reisner
@ 2011-09-29 23:42   ` Karel Zak
  0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2011-09-29 23:42 UTC (permalink / raw)
  To: Dave Reisner; +Cc: util-linux, Dave Reisner

On Thu, Sep 29, 2011 at 02:56:42PM -0400, Dave Reisner wrote:
>  include/xalloc.h |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

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

end of thread, other threads:[~2011-09-29 23:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-29 18:56 [PATCH 1/2] xalloc: check for NULL before calling strdup Dave Reisner
2011-09-29 18:56 ` [PATCH 2/2] xalloc: fix whitespace to be consistent Dave Reisner
2011-09-29 23:42   ` Karel Zak
2011-09-29 23:42 ` [PATCH 1/2] xalloc: check for NULL before calling strdup Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).