Permalink
Browse files

Bug 826173 - Avoid calling close/fclose/unlink with uninitialized val…

…ues in the linker. r=nfroyd
  • Loading branch information...
1 parent 8862d96 commit 82e356b88ffe6645e052de46c26f3f9c14ed32eb @glandium glandium committed Jan 3, 2013
Showing with 4 additions and 2 deletions.
  1. +2 −0 mozglue/linker/Mappable.h
  2. +2 −2 mozglue/linker/Utils.h
@@ -114,6 +114,8 @@ class MappableExtractFile: public MappableFile
{
static void release(char *value)
{
+ if (!value)
+ return;
unlink(value);
mozilla::ScopedDeleteArrayTraits<char>::release(value);
}
View
@@ -86,7 +86,7 @@ struct AutoCloseFDTraits
{
typedef int type;
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;
@@ -97,7 +97,7 @@ struct AutoCloseFILETraits
{
typedef FILE *type;
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;

0 comments on commit 82e356b

Please sign in to comment.