[BZ,#17657] Return allocated array instead array on stack.
diff mbox

Message ID 20141210132153.GA6395@domone
State New
Headers show

Commit Message

Ondřej Bílka Dec. 10, 2014, 1:21 p.m. UTC
Hi,

here we return array on stack which is invalid. OK to fix it in obvious way?

	[BZ #17657]
	* locale/programs/ld-ctype.c (find_translit2): Allocate returned array.

Comments

Andreas Schwab Dec. 10, 2014, 2:09 p.m. UTC | #1
Ondřej Bílka <neleai@seznam.cz> writes:

> here we return array on stack which is invalid. OK to fix it in obvious way?

The obvious way would be a static allocation.

Andreas.
Ondřej Bílka Dec. 10, 2014, 2:32 p.m. UTC | #2
On Wed, Dec 10, 2014 at 03:09:53PM +0100, Andreas Schwab wrote:
> Ondřej Bílka <neleai@seznam.cz> writes:
> 
> > here we return array on stack which is invalid. OK to fix it in obvious way?
> 
> The obvious way would be a static allocation.
> 
which breaks when user modifies array.
Andreas Schwab Dec. 10, 2014, 2:50 p.m. UTC | #3
Ondřej Bílka <neleai@seznam.cz> writes:

> On Wed, Dec 10, 2014 at 03:09:53PM +0100, Andreas Schwab wrote:
>> Ondřej Bílka <neleai@seznam.cz> writes:
>> 
>> > here we return array on stack which is invalid. OK to fix it in obvious way?
>> 
>> The obvious way would be a static allocation.
>> 
> which breaks when user modifies array.

Which user?

Andreas.

Patch
diff mbox

diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 67846b3..103fc63 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -1777,7 +1777,7 @@  find_translit2 (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
 
 	  for (wi = tirunp->from; wi <= wch; wi += tirunp->step)
 	    if (wi == wch)
-	      return (uint32_t []) { 0 };
+	      return (uint32_t *) xcalloc (1, sizeof (uint32_t));
 	}
     }