Skip to content

Commit

Permalink
File descriptor leak on PRINT_UNSYMBOLIZED_STACK_TRACES mode
Browse files Browse the repository at this point in the history
When PRINT_UNSYMBOLIZED_STACK_TRACES is on, |object_fd| is created in
|SymbolizeAndDemangle| but not used. The handle is not closed when
returning the function.

This CL fixes this file descriptor leak by using FileDescriptor.

Change-Id: I216c00690946671edd802f91fd694573d5783ba0
Reviewed-on: https://chromium-review.googlesource.com/1120087
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574087}
  • Loading branch information
Hajime Hoshi authored and Commit Bot committed Jul 11, 2018
1 parent 7d5cd5b commit 5a46173
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions base/third_party/symbolize/symbolize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,11 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
out_size - 1);
}

#if defined(PRINT_UNSYMBOLIZED_STACK_TRACES)
{
FileDescriptor wrapped_object_fd(object_fd);
#else
// Check whether a file name was returned.
#if !defined(PRINT_UNSYMBOLIZED_STACK_TRACES)
if (object_fd < 0) {
#endif
if (out[1]) {
Expand All @@ -795,9 +798,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
}
// Failed to determine the object file containing PC. Bail out.
return false;
#if !defined(PRINT_UNSYMBOLIZED_STACK_TRACES)
}
#endif
FileDescriptor wrapped_object_fd(object_fd);
int elf_type = FileGetElfType(wrapped_object_fd.get());
if (elf_type == -1) {
Expand Down

0 comments on commit 5a46173

Please sign in to comment.