Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak and resource leak bugfixing #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions caapt/RMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions caapt/Resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,6 +2660,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
className, 0, bundle->getNonConstantId(), emitCallback);
fclose(fp);
if (err != NO_ERROR) {
free(dest_r_path);
return err;
}

Expand All @@ -2672,6 +2673,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& 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()) {
Expand All @@ -2682,6 +2684,7 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
className);
fclose(fp);
if (err != NO_ERROR) {
free(dest_r_path);
return err;
}
}
Expand Down
4 changes: 4 additions & 0 deletions caapt/printapk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down