Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Bug 826173 - Avoid calling close/fclose/unlink with uninitialized val…
Browse files Browse the repository at this point in the history
…ues in the linker. r=nfroyd
  • Loading branch information
glandium committed Jan 3, 2013
1 parent 8862d96 commit 82e356b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mozglue/linker/Mappable.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class MappableExtractFile: public MappableFile
{ {
static void release(char *value) static void release(char *value)
{ {
if (!value)
return;
unlink(value); unlink(value);
mozilla::ScopedDeleteArrayTraits<char>::release(value); mozilla::ScopedDeleteArrayTraits<char>::release(value);
} }
Expand Down
4 changes: 2 additions & 2 deletions mozglue/linker/Utils.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct AutoCloseFDTraits
{ {
typedef int type; typedef int type;
static int empty() { return -1; } static int empty() { return -1; }
static void release(int fd) { close(fd); } static void release(int fd) { if (fd != -1) close(fd); }
}; };
typedef mozilla::Scoped<AutoCloseFDTraits> AutoCloseFD; typedef mozilla::Scoped<AutoCloseFDTraits> AutoCloseFD;


Expand All @@ -97,7 +97,7 @@ struct AutoCloseFILETraits
{ {
typedef FILE *type; typedef FILE *type;
static FILE *empty() { return NULL; } static FILE *empty() { return NULL; }
static void release(FILE *f) { fclose(f); } static void release(FILE *f) { if (f) fclose(f); }
}; };
typedef mozilla::Scoped<AutoCloseFILETraits> AutoCloseFILE; typedef mozilla::Scoped<AutoCloseFILETraits> AutoCloseFILE;


Expand Down

0 comments on commit 82e356b

Please sign in to comment.