Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/fuzz/number.cpp
2723 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#include "Luau/Common.h"
3
4
#include <stdint.h>
5
#include <stddef.h>
6
#include <string.h>
7
#include <stdlib.h>
8
9
#define LUAI_MAXNUM2STR 48
10
11
char* luai_num2str(char* buf, double n);
12
13
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
14
{
15
if (Size < 8)
16
return 0;
17
18
double num;
19
memcpy(&num, Data, 8);
20
21
char buf[LUAI_MAXNUM2STR];
22
char* end = luai_num2str(buf, num);
23
LUAU_ASSERT(end < buf + sizeof(buf));
24
25
*end = 0;
26
27
double rec = strtod(buf, nullptr);
28
29
LUAU_ASSERT(rec == num || (rec != rec && num != num));
30
return 0;
31
}
32
33