// Copyright 2011 Google Inc. All Rights Reserved.
// This file is available under the Apache license.

// +build gofuzz

package vm

import (
	"bytes"
)

func Fuzz(data []byte) int {
	if _, err := Compile("fuzz", bytes.NewReader(data), false, false, false, nil); err != nil {
		return 0
	}
	return 1
}

// Copyright 2011 Google Inc. All Rights Reserved.
// This file is available under the Apache license.

// +build gofuzz

package vm

import (
	"bytes"
)

func Fuzz(data []byte) int {
	// We need to successfully parse flags to initialize the glog logger used
	// by the compiler, but the fuzzer gets called with flags captured by the
	// libfuzzer main, which we don't want to intercept here.
	flag.Commandline = flag.NewFlagSet("", flag.ContinueOnError)
	flag.Parse()
	if _, err := Compile("fuzz", bytes.NewReader(data), false, false, false, nil); err != nil {
		return 0
	}
	return 1
}

Initialize the flags so that the glogger doesn't log that we haven't done so, but try to avoid intercepting the libFuzzer main's flags.
Initialize the flags so that the glogger doesn't log that we haven't done so,
but try to avoid intercepting the libFuzzer main's flags.

Issue #256
