Commit 10aa0d7b authored by Dokyung Song's avatar Dokyung Song Committed by Matt Morehouse
Browse files

[compiler-rt] Fix compiler warnings and runtime errors in sanitizer RT strxfrm(_l) test cases.

Summary: Fixed an implicit definition warning by including <string.h>. Also fixed run-time assertions that the return value of strxfrm_l calls is less than the buffer size by increasing the size of the referenced buffer.

Reviewers: morehouse

Reviewed By: morehouse

Subscribers: dberris, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D83593
parent bfa3b627
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
extern "C" decltype(strxfrm_l) __strxfrm_l;

int main(void) {
  char q[10];
  char q[100];
  locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
  size_t n = __strxfrm_l(q, "qwerty", sizeof(q), loc);
  assert(n < sizeof(q));
+3 −3
Original line number Diff line number Diff line
@@ -3,16 +3,16 @@

#include <assert.h>
#include <locale.h>
#include <wchar.h>
#include <string.h>

int main(int argc, char **argv) {
  char q[10];
  size_t n = strxfrm(q, "abcdef", sizeof(q));
  assert(n < sizeof(q));

  char q2[10];
  char q2[100];
  locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
  n = strxfrm_l(q2, L"qwerty", sizeof(q), loc);
  n = strxfrm_l(q2, "qwerty", sizeof(q2), loc);
  assert(n < sizeof(q2));

  freelocale(loc);