diff options
-rw-r--r-- | mpq-bios.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -476,13 +476,13 @@ int mpqlib_add_hash_entry_by_hash(struct mpq_archive_t * mpq_a, uint32_t h, uint } int mpqlib_add_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * name, uint16_t language, uint16_t platform, int entry) { + uint32_t h, hA, hB; + if (!mpq_a->for_write) { __mpqlib_errno = MPQLIB_ERROR_READONLY; return -1; } - uint32_t h, hA, hB; - h = mpqlib_hash_filename(name); hA = mpqlib_hashA_filename(name); hB = mpqlib_hashB_filename(name); @@ -491,13 +491,13 @@ int mpqlib_add_hash_entry_by_name(struct mpq_archive_t * mpq_a, const char * nam } int mpqlib_update_hash_entry_by_hash(struct mpq_archive_t * mpq_a, uint32_t h, uint32_t hA, uint32_t hB, uint16_t language, uint16_t platform, int entry) { + hash_t * hash = mpqlib_locate_hash_entry(mpq_a, h, hA, hB, language, platform); + if (!mpq_a->for_write) { __mpqlib_errno = MPQLIB_ERROR_READONLY; return -1; } - hash_t * hash = mpqlib_locate_hash_entry(mpq_a, h, hA, hB, language, platform); - if (hash) { hash->file_block_index = entry; return 0; |