macho.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /*************************************************************************/
  2. /* macho.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "modules/modules_enabled.gen.h" // For regex.
  31. #include "macho.h"
  32. #ifdef MODULE_REGEX_ENABLED
  33. uint32_t MachO::seg_align(uint64_t p_vmaddr, uint32_t p_min, uint32_t p_max) {
  34. uint32_t align = p_max;
  35. if (p_vmaddr != 0) {
  36. uint64_t seg_align = 1;
  37. align = 0;
  38. while ((seg_align & p_vmaddr) == 0) {
  39. seg_align = seg_align << 1;
  40. align++;
  41. }
  42. align = CLAMP(align, p_min, p_max);
  43. }
  44. return align;
  45. }
  46. bool MachO::alloc_signature(uint64_t p_size) {
  47. ERR_FAIL_COND_V_MSG(!fa, false, "MachO: File not opened.");
  48. if (signature_offset != 0) {
  49. // Nothing to do, already have signature load command.
  50. return true;
  51. }
  52. if (lc_limit == 0 || lc_limit + 16 > exe_base) {
  53. ERR_FAIL_V_MSG(false, "MachO: Can't allocate signature load command, please use \"codesign_allocate\" utility first.");
  54. } else {
  55. // Add signature load command.
  56. signature_offset = lc_limit;
  57. fa->seek(lc_limit);
  58. LoadCommandHeader lc;
  59. lc.cmd = LC_CODE_SIGNATURE;
  60. lc.cmdsize = 16;
  61. if (swap) {
  62. lc.cmdsize = BSWAP32(lc.cmdsize);
  63. }
  64. fa->store_buffer((const uint8_t *)&lc, sizeof(LoadCommandHeader));
  65. uint32_t lc_offset = fa->get_length() + PAD(fa->get_length(), 16);
  66. uint32_t lc_size = 0;
  67. if (swap) {
  68. lc_offset = BSWAP32(lc_offset);
  69. lc_size = BSWAP32(lc_size);
  70. }
  71. fa->store_32(lc_offset);
  72. fa->store_32(lc_size);
  73. // Write new command number.
  74. fa->seek(0x10);
  75. uint32_t ncmds = fa->get_32();
  76. uint32_t cmdssize = fa->get_32();
  77. if (swap) {
  78. ncmds = BSWAP32(ncmds);
  79. cmdssize = BSWAP32(cmdssize);
  80. }
  81. ncmds += 1;
  82. cmdssize += 16;
  83. if (swap) {
  84. ncmds = BSWAP32(ncmds);
  85. cmdssize = BSWAP32(cmdssize);
  86. }
  87. fa->seek(0x10);
  88. fa->store_32(ncmds);
  89. fa->store_32(cmdssize);
  90. lc_limit = lc_limit + sizeof(LoadCommandHeader) + 8;
  91. return true;
  92. }
  93. }
  94. bool MachO::is_macho(const String &p_path) {
  95. FileAccessRef fb = FileAccess::open(p_path, FileAccess::READ);
  96. ERR_FAIL_COND_V_MSG(!fb, false, vformat("MachO: Can't open file: \"%s\".", p_path));
  97. uint32_t magic = fb->get_32();
  98. return (magic == 0xcefaedfe || magic == 0xfeedface || magic == 0xcffaedfe || magic == 0xfeedfacf);
  99. }
  100. bool MachO::open_file(const String &p_path) {
  101. fa = FileAccess::open(p_path, FileAccess::READ_WRITE);
  102. ERR_FAIL_COND_V_MSG(!fa, false, vformat("MachO: Can't open file: \"%s\".", p_path));
  103. uint32_t magic = fa->get_32();
  104. MachHeader mach_header;
  105. // Read MachO header.
  106. swap = (magic == 0xcffaedfe || magic == 0xcefaedfe);
  107. if (magic == 0xcefaedfe || magic == 0xfeedface) {
  108. // Thin 32-bit binary.
  109. fa->get_buffer((uint8_t *)&mach_header, sizeof(MachHeader));
  110. } else if (magic == 0xcffaedfe || magic == 0xfeedfacf) {
  111. // Thin 64-bit binary.
  112. fa->get_buffer((uint8_t *)&mach_header, sizeof(MachHeader));
  113. fa->get_32(); // Skip extra reserved field.
  114. } else {
  115. ERR_FAIL_V_MSG(false, vformat("MachO: File is not a valid MachO binary: \"%s\".", p_path));
  116. }
  117. if (swap) {
  118. mach_header.ncmds = BSWAP32(mach_header.ncmds);
  119. mach_header.cpusubtype = BSWAP32(mach_header.cpusubtype);
  120. mach_header.cputype = BSWAP32(mach_header.cputype);
  121. }
  122. cpusubtype = mach_header.cpusubtype;
  123. cputype = mach_header.cputype;
  124. align = 0;
  125. exe_base = std::numeric_limits<uint64_t>::max();
  126. exe_limit = 0;
  127. lc_limit = 0;
  128. link_edit_offset = 0;
  129. signature_offset = 0;
  130. // Read load commands.
  131. for (uint32_t i = 0; i < mach_header.ncmds; i++) {
  132. LoadCommandHeader lc;
  133. fa->get_buffer((uint8_t *)&lc, sizeof(LoadCommandHeader));
  134. if (swap) {
  135. lc.cmd = BSWAP32(lc.cmd);
  136. lc.cmdsize = BSWAP32(lc.cmdsize);
  137. }
  138. uint64_t ps = fa->get_position();
  139. switch (lc.cmd) {
  140. case LC_SEGMENT: {
  141. LoadCommandSegment lc_seg;
  142. fa->get_buffer((uint8_t *)&lc_seg, sizeof(LoadCommandSegment));
  143. if (swap) {
  144. lc_seg.nsects = BSWAP32(lc_seg.nsects);
  145. lc_seg.vmaddr = BSWAP32(lc_seg.vmaddr);
  146. lc_seg.vmsize = BSWAP32(lc_seg.vmsize);
  147. }
  148. align = MAX(align, seg_align(lc_seg.vmaddr, 2, 15));
  149. if (String(lc_seg.segname) == "__TEXT") {
  150. exe_limit = MAX(exe_limit, lc_seg.vmsize);
  151. for (uint32_t j = 0; j < lc_seg.nsects; j++) {
  152. Section lc_sect;
  153. fa->get_buffer((uint8_t *)&lc_sect, sizeof(Section));
  154. if (String(lc_sect.sectname) == "__text") {
  155. if (swap) {
  156. exe_base = MIN(exe_base, BSWAP32(lc_sect.offset));
  157. } else {
  158. exe_base = MIN(exe_base, lc_sect.offset);
  159. }
  160. }
  161. if (swap) {
  162. align = MAX(align, BSWAP32(lc_sect.align));
  163. } else {
  164. align = MAX(align, lc_sect.align);
  165. }
  166. }
  167. } else if (String(lc_seg.segname) == "__LINKEDIT") {
  168. link_edit_offset = ps - 8;
  169. }
  170. } break;
  171. case LC_SEGMENT_64: {
  172. LoadCommandSegment64 lc_seg;
  173. fa->get_buffer((uint8_t *)&lc_seg, sizeof(LoadCommandSegment64));
  174. if (swap) {
  175. lc_seg.nsects = BSWAP32(lc_seg.nsects);
  176. lc_seg.vmaddr = BSWAP64(lc_seg.vmaddr);
  177. lc_seg.vmsize = BSWAP64(lc_seg.vmsize);
  178. }
  179. align = MAX(align, seg_align(lc_seg.vmaddr, 3, 15));
  180. if (String(lc_seg.segname) == "__TEXT") {
  181. exe_limit = MAX(exe_limit, lc_seg.vmsize);
  182. for (uint32_t j = 0; j < lc_seg.nsects; j++) {
  183. Section64 lc_sect;
  184. fa->get_buffer((uint8_t *)&lc_sect, sizeof(Section64));
  185. if (String(lc_sect.sectname) == "__text") {
  186. if (swap) {
  187. exe_base = MIN(exe_base, BSWAP32(lc_sect.offset));
  188. } else {
  189. exe_base = MIN(exe_base, lc_sect.offset);
  190. }
  191. if (swap) {
  192. align = MAX(align, BSWAP32(lc_sect.align));
  193. } else {
  194. align = MAX(align, lc_sect.align);
  195. }
  196. }
  197. }
  198. } else if (String(lc_seg.segname) == "__LINKEDIT") {
  199. link_edit_offset = ps - 8;
  200. }
  201. } break;
  202. case LC_CODE_SIGNATURE: {
  203. signature_offset = ps - 8;
  204. } break;
  205. default: {
  206. } break;
  207. }
  208. fa->seek(ps + lc.cmdsize - 8);
  209. lc_limit = ps + lc.cmdsize - 8;
  210. }
  211. if (exe_limit == 0 || lc_limit == 0) {
  212. ERR_FAIL_V_MSG(false, vformat("MachO: No load commands or executable code found: \"%s\".", p_path));
  213. }
  214. return true;
  215. }
  216. uint64_t MachO::get_exe_base() {
  217. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  218. return exe_base;
  219. }
  220. uint64_t MachO::get_exe_limit() {
  221. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  222. return exe_limit;
  223. }
  224. int32_t MachO::get_align() {
  225. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  226. return align;
  227. }
  228. uint32_t MachO::get_cputype() {
  229. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  230. return cputype;
  231. }
  232. uint32_t MachO::get_cpusubtype() {
  233. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  234. return cpusubtype;
  235. }
  236. uint64_t MachO::get_size() {
  237. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  238. return fa->get_length();
  239. }
  240. uint64_t MachO::get_signature_offset() {
  241. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  242. ERR_FAIL_COND_V_MSG(signature_offset == 0, 0, "MachO: No signature load command.");
  243. fa->seek(signature_offset + 8);
  244. if (swap) {
  245. return BSWAP32(fa->get_32());
  246. } else {
  247. return fa->get_32();
  248. }
  249. }
  250. uint64_t MachO::get_code_limit() {
  251. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  252. if (signature_offset == 0) {
  253. return fa->get_length() + PAD(fa->get_length(), 16);
  254. } else {
  255. return get_signature_offset();
  256. }
  257. }
  258. uint64_t MachO::get_signature_size() {
  259. ERR_FAIL_COND_V_MSG(!fa, 0, "MachO: File not opened.");
  260. ERR_FAIL_COND_V_MSG(signature_offset == 0, 0, "MachO: No signature load command.");
  261. fa->seek(signature_offset + 12);
  262. if (swap) {
  263. return BSWAP32(fa->get_32());
  264. } else {
  265. return fa->get_32();
  266. }
  267. }
  268. bool MachO::is_signed() {
  269. ERR_FAIL_COND_V_MSG(!fa, false, "MachO: File not opened.");
  270. if (signature_offset == 0) {
  271. return false;
  272. }
  273. fa->seek(get_signature_offset());
  274. uint32_t magic = BSWAP32(fa->get_32());
  275. if (magic != 0xfade0cc0) {
  276. return false; // No SuperBlob found.
  277. }
  278. fa->get_32(); // Skip size field, unused.
  279. uint32_t count = BSWAP32(fa->get_32());
  280. for (uint32_t i = 0; i < count; i++) {
  281. uint32_t index_type = BSWAP32(fa->get_32());
  282. uint32_t offset = BSWAP32(fa->get_32());
  283. if (index_type == 0x00000000) { // CodeDirectory index type.
  284. fa->seek(get_signature_offset() + offset + 12);
  285. uint32_t flags = BSWAP32(fa->get_32());
  286. if (flags & 0x20000) {
  287. return false; // Found CD, linker-signed.
  288. } else {
  289. return true; // Found CD, not linker-signed.
  290. }
  291. }
  292. }
  293. return false; // No CD found.
  294. }
  295. PackedByteArray MachO::get_cdhash_sha1() {
  296. ERR_FAIL_COND_V_MSG(!fa, PackedByteArray(), "MachO: File not opened.");
  297. if (signature_offset == 0) {
  298. return PackedByteArray();
  299. }
  300. fa->seek(get_signature_offset());
  301. uint32_t magic = BSWAP32(fa->get_32());
  302. if (magic != 0xfade0cc0) {
  303. return PackedByteArray(); // No SuperBlob found.
  304. }
  305. fa->get_32(); // Skip size field, unused.
  306. uint32_t count = BSWAP32(fa->get_32());
  307. for (uint32_t i = 0; i < count; i++) {
  308. fa->get_32(); // Index type, skip.
  309. uint32_t offset = BSWAP32(fa->get_32());
  310. uint64_t pos = fa->get_position();
  311. fa->seek(get_signature_offset() + offset);
  312. uint32_t cdmagic = BSWAP32(fa->get_32());
  313. uint32_t cdsize = BSWAP32(fa->get_32());
  314. if (cdmagic == 0xfade0c02) { // CodeDirectory.
  315. fa->seek(get_signature_offset() + offset + 36);
  316. uint8_t hash_size = fa->get_8();
  317. uint8_t hash_type = fa->get_8();
  318. if (hash_size == 0x14 && hash_type == 0x01) { /* SHA-1 */
  319. PackedByteArray hash;
  320. hash.resize(0x14);
  321. fa->seek(get_signature_offset() + offset);
  322. PackedByteArray blob;
  323. blob.resize(cdsize);
  324. fa->get_buffer(blob.ptrw(), cdsize);
  325. CryptoCore::SHA1Context ctx;
  326. ctx.start();
  327. ctx.update(blob.ptr(), blob.size());
  328. ctx.finish(hash.ptrw());
  329. return hash;
  330. }
  331. }
  332. fa->seek(pos);
  333. }
  334. return PackedByteArray();
  335. }
  336. PackedByteArray MachO::get_cdhash_sha256() {
  337. ERR_FAIL_COND_V_MSG(!fa, PackedByteArray(), "MachO: File not opened.");
  338. if (signature_offset == 0) {
  339. return PackedByteArray();
  340. }
  341. fa->seek(get_signature_offset());
  342. uint32_t magic = BSWAP32(fa->get_32());
  343. if (magic != 0xfade0cc0) {
  344. return PackedByteArray(); // No SuperBlob found.
  345. }
  346. fa->get_32(); // Skip size field, unused.
  347. uint32_t count = BSWAP32(fa->get_32());
  348. for (uint32_t i = 0; i < count; i++) {
  349. fa->get_32(); // Index type, skip.
  350. uint32_t offset = BSWAP32(fa->get_32());
  351. uint64_t pos = fa->get_position();
  352. fa->seek(get_signature_offset() + offset);
  353. uint32_t cdmagic = BSWAP32(fa->get_32());
  354. uint32_t cdsize = BSWAP32(fa->get_32());
  355. if (cdmagic == 0xfade0c02) { // CodeDirectory.
  356. fa->seek(get_signature_offset() + offset + 36);
  357. uint8_t hash_size = fa->get_8();
  358. uint8_t hash_type = fa->get_8();
  359. if (hash_size == 0x20 && hash_type == 0x02) { /* SHA-256 */
  360. PackedByteArray hash;
  361. hash.resize(0x20);
  362. fa->seek(get_signature_offset() + offset);
  363. PackedByteArray blob;
  364. blob.resize(cdsize);
  365. fa->get_buffer(blob.ptrw(), cdsize);
  366. CryptoCore::SHA256Context ctx;
  367. ctx.start();
  368. ctx.update(blob.ptr(), blob.size());
  369. ctx.finish(hash.ptrw());
  370. return hash;
  371. }
  372. }
  373. fa->seek(pos);
  374. }
  375. return PackedByteArray();
  376. }
  377. PackedByteArray MachO::get_requirements() {
  378. ERR_FAIL_COND_V_MSG(!fa, PackedByteArray(), "MachO: File not opened.");
  379. if (signature_offset == 0) {
  380. return PackedByteArray();
  381. }
  382. fa->seek(get_signature_offset());
  383. uint32_t magic = BSWAP32(fa->get_32());
  384. if (magic != 0xfade0cc0) {
  385. return PackedByteArray(); // No SuperBlob found.
  386. }
  387. fa->get_32(); // Skip size field, unused.
  388. uint32_t count = BSWAP32(fa->get_32());
  389. for (uint32_t i = 0; i < count; i++) {
  390. fa->get_32(); // Index type, skip.
  391. uint32_t offset = BSWAP32(fa->get_32());
  392. uint64_t pos = fa->get_position();
  393. fa->seek(get_signature_offset() + offset);
  394. uint32_t rqmagic = BSWAP32(fa->get_32());
  395. uint32_t rqsize = BSWAP32(fa->get_32());
  396. if (rqmagic == 0xfade0c01) { // Requirements.
  397. PackedByteArray blob;
  398. fa->seek(get_signature_offset() + offset);
  399. blob.resize(rqsize);
  400. fa->get_buffer(blob.ptrw(), rqsize);
  401. return blob;
  402. }
  403. fa->seek(pos);
  404. }
  405. return PackedByteArray();
  406. }
  407. const FileAccess *MachO::get_file() const {
  408. return fa;
  409. }
  410. FileAccess *MachO::get_file() {
  411. return fa;
  412. }
  413. bool MachO::set_signature_size(uint64_t p_size) {
  414. ERR_FAIL_COND_V_MSG(!fa, false, "MachO: File not opened.");
  415. // Ensure signature load command exists.
  416. ERR_FAIL_COND_V_MSG(link_edit_offset == 0, false, "MachO: No __LINKEDIT segment found.");
  417. ERR_FAIL_COND_V_MSG(!alloc_signature(p_size), false, "MachO: Can't allocate signature load command.");
  418. // Update signature load command.
  419. uint64_t old_size = get_signature_size();
  420. uint64_t new_size = p_size + PAD(p_size, 16384);
  421. if (new_size <= old_size) {
  422. fa->seek(get_signature_offset());
  423. for (uint64_t i = 0; i < old_size; i++) {
  424. fa->store_8(0x00);
  425. }
  426. return true;
  427. }
  428. fa->seek(signature_offset + 12);
  429. if (swap) {
  430. fa->store_32(BSWAP32(new_size));
  431. } else {
  432. fa->store_32(new_size);
  433. }
  434. uint64_t end = get_signature_offset() + new_size;
  435. // Update "__LINKEDIT" segment.
  436. LoadCommandHeader lc;
  437. fa->seek(link_edit_offset);
  438. fa->get_buffer((uint8_t *)&lc, sizeof(LoadCommandHeader));
  439. if (swap) {
  440. lc.cmd = BSWAP32(lc.cmd);
  441. lc.cmdsize = BSWAP32(lc.cmdsize);
  442. }
  443. switch (lc.cmd) {
  444. case LC_SEGMENT: {
  445. LoadCommandSegment lc_seg;
  446. fa->get_buffer((uint8_t *)&lc_seg, sizeof(LoadCommandSegment));
  447. if (swap) {
  448. lc_seg.vmsize = BSWAP32(lc_seg.vmsize);
  449. lc_seg.filesize = BSWAP32(lc_seg.filesize);
  450. lc_seg.fileoff = BSWAP32(lc_seg.fileoff);
  451. }
  452. lc_seg.vmsize = end - lc_seg.fileoff;
  453. lc_seg.vmsize += PAD(lc_seg.vmsize, 4096);
  454. lc_seg.filesize = end - lc_seg.fileoff;
  455. if (swap) {
  456. lc_seg.vmsize = BSWAP32(lc_seg.vmsize);
  457. lc_seg.filesize = BSWAP32(lc_seg.filesize);
  458. }
  459. fa->seek(link_edit_offset + 8);
  460. fa->store_buffer((const uint8_t *)&lc_seg, sizeof(LoadCommandSegment));
  461. } break;
  462. case LC_SEGMENT_64: {
  463. LoadCommandSegment64 lc_seg;
  464. fa->get_buffer((uint8_t *)&lc_seg, sizeof(LoadCommandSegment64));
  465. if (swap) {
  466. lc_seg.vmsize = BSWAP64(lc_seg.vmsize);
  467. lc_seg.filesize = BSWAP64(lc_seg.filesize);
  468. lc_seg.fileoff = BSWAP64(lc_seg.fileoff);
  469. }
  470. lc_seg.vmsize = end - lc_seg.fileoff;
  471. lc_seg.vmsize += PAD(lc_seg.vmsize, 4096);
  472. lc_seg.filesize = end - lc_seg.fileoff;
  473. if (swap) {
  474. lc_seg.vmsize = BSWAP64(lc_seg.vmsize);
  475. lc_seg.filesize = BSWAP64(lc_seg.filesize);
  476. }
  477. fa->seek(link_edit_offset + 8);
  478. fa->store_buffer((const uint8_t *)&lc_seg, sizeof(LoadCommandSegment64));
  479. } break;
  480. default: {
  481. ERR_FAIL_V_MSG(false, "MachO: Invalid __LINKEDIT segment type.");
  482. } break;
  483. }
  484. fa->seek(get_signature_offset());
  485. for (uint64_t i = 0; i < new_size; i++) {
  486. fa->store_8(0x00);
  487. }
  488. return true;
  489. }
  490. MachO::~MachO() {
  491. if (fa) {
  492. fa->close();
  493. memdelete(fa);
  494. fa = nullptr;
  495. }
  496. }
  497. #endif // MODULE_REGEX_ENABLED