blob: 74596c4c9945acb29d54a26ccadacf9adebe6809 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/* { dg-do compile }
{ dg-options "-O2 -Wstringop-overflow" } */
extern char* strchr (const char*, int);
extern char* strcpy (char*, const char*);
extern void* malloc (__SIZE_TYPE__);
extern __SIZE_TYPE__ strlen (const char *);
struct define_item {
int len;
char value[1];
};
struct define_item * foo(char *name)
{
char * p;
char * value;
struct define_item * ptr;
p = strchr (name, '=');
if (1 && p) {
value = p+1;
} else
value = "1";
ptr = malloc(sizeof(struct define_item) + strlen(value));
strcpy(ptr->value, value); /* { dg-bogus "bytes into a region" } */
return ptr;
}
|