#include <maya/MPxCommand.h>
#include <maya/MGlobal.h>
#include <maya/MArgList.h>
#include <maya/MGlobal.h>
#include <maya/MString.h>
#include <maya/MFnPlugin.h>
#include <math.h>
#include <stdio.h>
#include <assert.h>
#include <maya/MApiNamespace.h>
static const char *helpArray[] = {
"Synopsis : crash [flags]\n",
" -a/allocation : Crash through excessive memory allocation\n",
" -m/melCommand : A magic Mel script syntax error that crashes the command engine\n",
" -n/nullPointer : Illegal memory access through a zero pointer\n"
};
{
public:
crashAction() {}
~crashAction() override {}
bool isUndoable()
const override {
return false; }
static void *creator() { return new crashAction(); }
};
{
bool didSomething = false;
for (
unsigned i = 0; i < args.
length(); i++)
{
{
for (unsigned int i = 0; i < 0xffffffff; ++i)
{
(void)malloc(0xfffffffffffffff);
}
didSomething = true;
}
{
MString command(
"global proc crashMe(, int $test ) {}");
didSomething = true;
}
{
printf(
"Printing an invalid value %s\n", nullStr->
asChar());
didSomething = true;
}
}
if (!didSomething)
{
unsigned int helpCount = sizeof(helpArray) / sizeof(helpArray[0]);
for (unsigned int j = 0; j < helpCount; j++)
{
appendToResult(
MString(helpArray[j]));
}
return MS::kSuccess;
}
return MS::kFailure;
}
{
MFnPlugin plugin(obj,
"Autodesk",
"4.0",
"Any");
status = plugin.registerCommand("crash", crashAction::creator);
if (!status)
{
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand("crash");
if (!status)
{
status.
perror(
"deregisterCommand");
return status;
}
return status;
}