@@ -52,13 +52,6 @@ struct metrics {
52
52
53
53
static struct metrics metrics;
54
54
55
- static void
56
- Hook (lua_State *L, lua_Debug *ar)
57
- {
58
- (void )L;
59
- (void )ar;
60
- }
61
-
62
55
UNUSED static void
63
56
jit_attach (lua_State *L, void *func, const char *event)
64
57
{
@@ -260,73 +253,6 @@ disable_lj_metrics(lua_State *L, struct metrics *metrics)
260
253
jit_attach (L, (void *)trace_cb, NULL );
261
254
}
262
255
263
- struct str_Writer {
264
- /* Non-zero when buffer has been initialized. */
265
- int init;
266
- luaL_Buffer B;
267
- size_t bufsize;
268
- };
269
-
270
- static int
271
- writer (lua_State *L, const void *b, size_t size, void *ud) {
272
- struct str_Writer *state = (struct str_Writer *)ud;
273
- if (!state->init ) {
274
- state->init = 1 ;
275
- luaL_buffinit (L, &state->B );
276
- }
277
- /* Finishing dump? */
278
- if (b == NULL ) {
279
- luaL_pushresult (&state->B );
280
- /* Move result to reserved slot. */
281
- lua_replace (L, 1 );
282
- }
283
- else {
284
- luaL_addlstring (&state->B , (const char *)b, size);
285
- state->bufsize += size;
286
- }
287
- return 0 ;
288
- }
289
-
290
- /*
291
- * Loads a buffer as a Lua bytecode chunk. This function uses luaL_loadstring
292
- * to load the chunk in the buffer pointed to by buff, lua_dump to dump
293
- * produced bytecode and luaL_loadbuffer to load produced bytecode to the
294
- * stack. This function returns the same results as luaL_loadbuffer.
295
- * name is the chunk name, used for debug information and error messages.
296
- */
297
- static int
298
- luaL_loadbytecode (lua_State *L, const char *buff, size_t sz, const char *name)
299
- {
300
- /* Compile Lua source code to bytecode. */
301
- int rc = luaL_loadstring (L, buff);
302
- if (rc != 0 ) {
303
- return LUA_ERRSYNTAX;
304
- }
305
-
306
- /* Dump a Lua bytecode to a buffer. */
307
- struct str_Writer state;
308
- memset (&state, 0 , sizeof (struct str_Writer ));
309
- #if LUA_VERSION_NUM < 503
310
- rc = lua_dump (L, writer, &state);
311
- #else /* Lua 5.3+ */
312
- rc = lua_dump (L, writer, &state, 0 );
313
- #endif /* LUA_VERSION_NUM */
314
- if (rc != 0 ) {
315
- return rc;
316
- }
317
-
318
- /* Leave final result on top. */
319
- lua_settop (L, 1 );
320
- const char *bc = lua_tolstring (L, -1 , &state.bufsize );
321
- /* Load Lua bytecode. */
322
- rc = luaL_loadbuffer (L, bc, state.bufsize , " bytecode" );
323
- if (rc != 0 ) {
324
- return rc;
325
- }
326
-
327
- return 0 ;
328
- }
329
-
330
256
DEFINE_PROTO_FUZZER (const lua_grammar::Block &message)
331
257
{
332
258
lua_State *L = luaL_newstate ();
@@ -342,11 +268,6 @@ DEFINE_PROTO_FUZZER(const lua_grammar::Block &message)
342
268
343
269
luaL_openlibs (L);
344
270
345
- int flag = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE;
346
- int count = 0 ;
347
- /* Enable debugging hook. */
348
- lua_sethook (L, Hook, flag, count);
349
-
350
271
#ifdef LUAJIT
351
272
enable_lj_metrics (L, &metrics);
352
273
@@ -399,21 +320,9 @@ DEFINE_PROTO_FUZZER(const lua_grammar::Block &message)
399
320
goto end;
400
321
}
401
322
402
- /*
403
- * With luaL_loadbytecode we build a bytecode from a Lua code and then
404
- * execute produced bytecode chunk.
405
- */
406
- if (luaL_loadbytecode (L, code.c_str (), code.size (), " fuzz" ) != LUA_OK)
407
- goto end;
408
-
409
- if (lua_pcall (L, 0 , 0 , 0 ) != LUA_OK) {
410
- report_error (L, " lua_pcall()" );
411
- }
412
-
413
323
end:
414
324
metrics_increment_num_samples (&metrics);
415
325
/* Disable debugging hook. */
416
- lua_sethook (L, Hook, 0 , count);
417
326
#ifdef LUAJIT
418
327
disable_lj_metrics (L, &metrics);
419
328
/* Stop profiler. */
0 commit comments