changeset 7861:28688a13afbc

Align the temporary buffer.
author Bruno Haible <bruno@clisp.org>
date Sat, 13 Jan 2007 14:47:41 +0000
parents 708da4ac0ccd
children 96c2288b426a
files ChangeLog lib/striconv.c
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-01-10  Bruno Haible  <bruno@clisp.org>
+
+	* lib/striconv.c (mem_cd_iconv): Align the temporary buffer.
+
 2007-01-12  Eric Blake  <ebb9@byu.net>
 
 	Provide a robust <wchar.h>.  Further simplifications are now
--- a/lib/striconv.c
+++ b/lib/striconv.c
@@ -1,5 +1,5 @@
 /* Charset conversion.
-   Copyright (C) 2001-2006 Free Software Foundation, Inc.
+   Copyright (C) 2001-2007 Free Software Foundation, Inc.
    Written by Bruno Haible and Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
@@ -59,7 +59,10 @@
   /* Determine the length we need.  */
   {
     size_t count = 0;
-    char tmpbuf[tmpbufsize];
+    /* The alignment is needed when converting e.g. to glibc's WCHAR_T or
+       libiconv's UCS-4-INTERNAL encoding.  */
+    union { unsigned int align; char buf[tmpbufsize]; } tmp;
+# define tmpbuf tmp.buf
     const char *inptr = src;
     size_t insize = srclen;
 
@@ -107,6 +110,7 @@
     }
 # endif
     length = count;
+# undef tmpbuf
   }
 
   if (length == 0)