aboutsummaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs/ext2fs_inline.c
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/ext2fs/ext2fs_inline.c')
-rw-r--r--e2fsprogs/ext2fs/ext2fs_inline.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/e2fsprogs/ext2fs/ext2fs_inline.c b/e2fsprogs/ext2fs/ext2fs_inline.c
index 73d393d20..a363b1992 100644
--- a/e2fsprogs/ext2fs/ext2fs_inline.c
+++ b/e2fsprogs/ext2fs/ext2fs_inline.c
@@ -44,12 +44,14 @@ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size,
44 unsigned long size, void *ptr) 44 unsigned long size, void *ptr)
45{ 45{
46 void *p; 46 void *p;
47 void **pp = (void **)ptr;
48 47
49 p = realloc(*pp, size); 48 /* Use "memcpy" for pointer assignments here to avoid problems
49 * with C99 strict type aliasing rules. */
50 memcpy(&p, ptr, sizeof (p));
51 p = realloc(p, size);
50 if (!p) 52 if (!p)
51 return EXT2_ET_NO_MEMORY; 53 return EXT2_ET_NO_MEMORY;
52 *pp = p; 54 memcpy(ptr, &p, sizeof (p));
53 return 0; 55 return 0;
54} 56}
55 57