https://bugs.kde.org/show_bug.cgi?id=475652

Arsen Arsenović <ar...@aarsen.me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ar...@aarsen.me

--- Comment #4 from Arsen Arsenović <ar...@aarsen.me> ---
Minimal reproducer:

#include <string.h>
#include <wchar.h>
#include <stdlib.h>

int
main ()
{
  wchar_t *bar = calloc(121, sizeof (wchar_t));
  wmemset (bar, 1, 120);

  wchar_t *foo = calloc(256, sizeof (wchar_t));
  wcsncpy (foo, bar, 255);
}

~$ gcc -O3 ~/test.c && valgrind ./a.out
==4093631== Memcheck, a memory error detector
==4093631== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==4093631== Using Valgrind-3.21.0 and LibVEX; rerun with -h for copyright info
==4093631== Command: ./a.out
==4093631== 
==4093631== Invalid read of size 32
==4093631==    at 0x49ECE2D: __wcsncpy_avx2 (strncpy-avx2.S:337)
==4093631==    by 0x1090B3: main (in /home/arsen/a.out)
==4093631==  Address 0x4a72240 is 16 bytes after a block of size 496 in arena
"client"
==4093631== 
==4093631== Conditional jump or move depends on uninitialised value(s)
==4093631==    at 0x49ECE51: __wcsncpy_avx2 (strncpy-avx2.S:348)
==4093631==    by 0x1090B3: main (in /home/arsen/a.out)
==4093631== 
==4093631== 
==4093631== HEAP SUMMARY:
==4093631==     in use at exit: 1,508 bytes in 2 blocks
==4093631==   total heap usage: 2 allocs, 0 frees, 1,508 bytes allocated
==4093631== 
==4093631== LEAK SUMMARY:
==4093631==    definitely lost: 1,508 bytes in 2 blocks
==4093631==    indirectly lost: 0 bytes in 0 blocks
==4093631==      possibly lost: 0 bytes in 0 blocks
==4093631==    still reachable: 0 bytes in 0 blocks
==4093631==         suppressed: 0 bytes in 0 blocks
==4093631== Rerun with --leak-check=full to see details of leaked memory
==4093631== 
==4093631== Use --track-origins=yes to see where uninitialised values come from
==4093631== For lists of detected and suppressed errors, rerun with: -s
==4093631== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
~$

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to