mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 00:22:57 -05:00
sceContentExportInit2 accepted any non-null parameter block. It now throws when the malloc or free function is missing or a reserved field is not zero. A test covers these refusals and the init and term order.
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#include "SceTypes.hpp"
|
|
#include <cstdlib>
|
|
#include <stdexcept>
|
|
|
|
extern "C" int APS5_VABI sceContentExportInit2(const ContentExportInitParam2* init_param);
|
|
extern "C" int APS5_VABI sceContentExportTerm(void);
|
|
|
|
namespace {
|
|
|
|
void Require(bool value) { if (!value) std::abort(); }
|
|
|
|
template <typename TAction>
|
|
bool Throws(TAction action) {
|
|
try {
|
|
action();
|
|
} catch (const std::logic_error&) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int allocator = 0;
|
|
|
|
}
|
|
|
|
int main() {
|
|
ContentExportInitParam2 param{&allocator, &allocator, nullptr, 0x10000, 0, 0};
|
|
Require(Throws([] { sceContentExportInit2(nullptr); }));
|
|
Require(Throws([] { sceContentExportTerm(); }));
|
|
ContentExportInitParam2 missing = param;
|
|
missing.free_func = nullptr;
|
|
Require(Throws([&] { sceContentExportInit2(&missing); }));
|
|
ContentExportInitParam2 reserved = param;
|
|
reserved.reserved1 = 1;
|
|
Require(Throws([&] { sceContentExportInit2(&reserved); }));
|
|
Require(sceContentExportInit2(¶m) == 0);
|
|
Require(Throws([&] { sceContentExportInit2(¶m); }));
|
|
Require(sceContentExportTerm() == 0);
|
|
Require(Throws([] { sceContentExportTerm(); }));
|
|
Require(sceContentExportInit2(¶m) == 0);
|
|
Require(sceContentExportTerm() == 0);
|
|
}
|