diff --git a/caapt/RMerge.cpp b/caapt/RMerge.cpp index 29fb170..63a6dde 100644 --- a/caapt/RMerge.cpp +++ b/caapt/RMerge.cpp @@ -102,6 +102,8 @@ int merge_r_file(const char* public_r_file_path, const char* project_r_file_path if (public_r_fp == NULL || project_r_fp == NULL) { printf("***********Error, read R.java failed, return -2;\n"); + fclose(public_r_fp); + fclose(project_r_fp); return -2; } @@ -206,6 +208,12 @@ int merge_r_file(const char* public_r_file_path, const char* project_r_file_path } else { printf("***********R.java file读取长度有错误, return -3;\n"); + fclose(public_r_fp); + fclose(project_r_fp); + c_free(public_r_str); + c_free(public_r_formated_str); + c_free(project_r_str); + c_free(output_r_str); return -3; } diff --git a/caapt/Resource.cpp b/caapt/Resource.cpp index 74c6be3..fb7d04d 100644 --- a/caapt/Resource.cpp +++ b/caapt/Resource.cpp @@ -2660,6 +2660,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp& assets, className, 0, bundle->getNonConstantId(), emitCallback); fclose(fp); if (err != NO_ERROR) { + free(dest_r_path); return err; } @@ -2672,6 +2673,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp& assets, if (fp == NULL) { fprintf(stderr, "ERROR: Unable to open text symbol file %s: %s\n", textDest.string(), strerror(errno)); + free(dest_r_path); return UNKNOWN_ERROR; } if (bundle->getVerbose()) { @@ -2682,6 +2684,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp& assets, className); fclose(fp); if (err != NO_ERROR) { + free(dest_r_path); return err; } } diff --git a/caapt/printapk.cpp b/caapt/printapk.cpp index def6e2e..f3297d6 100644 --- a/caapt/printapk.cpp +++ b/caapt/printapk.cpp @@ -52,18 +52,22 @@ main(int argc, char** argv) if (size < 0 || amt < 0) { fprintf(stderr, "apk: error determining file size: %s\n", filename); + close(fd); return 1; } buf = malloc(size); if (buf == NULL) { fprintf(stderr, "apk: file too big: %s\n", filename); + close(fd); return 1; } amt = read(fd, buf, size); if (amt != size) { fprintf(stderr, "apk: error reading file: %s\n", filename); + free(buf); + close(fd); return 1; }