Commit e302551e authored by André Bargull's avatar André Bargull
Browse files

Bug 1492090 - Part 1: Fix some comments, remove a #define, and make one fclose...

Bug 1492090 - Part 1: Fix some comments, remove a #define, and make one fclose call more robust. r=tcampbell

Differential Revision: https://phabricator.services.mozilla.com/D151445
parent 90f9330f
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -259,9 +259,7 @@ void XPCShellEnvironment::ProcessFile(JSContext* cx, const char* filename,
     * It's not interactive - just execute it.
     *
     * Support the UNIX #! shell hack; gobble the first line if it starts
     * with '#'.  TODO - this isn't quite compatible with sharp variables,
     * as a legal js program (using sharp variables) might start with '#'.
     * But that would require multi-character lookahead.
     * with '#'.
     */
    int ch = fgetc(file);
    if (ch == '#') {
+2 −2
Original line number Diff line number Diff line
@@ -233,8 +233,8 @@ class JS_PUBLIC_API TransitiveCompileOptions {
  bool deoptimizeModuleGlobalVars = false;

  /**
   * |introductionType| is a statically allocated C string: one of "eval",
   * "Function", or "GeneratorFunction".
   * |introductionType| is a statically allocated C string. See JSScript.h
   * for more information.
   */
  const char* introductionType = nullptr;

+5 −4
Original line number Diff line number Diff line
@@ -4173,6 +4173,11 @@ static bool DumpHeap(JSContext* cx, unsigned argc, Value* vp) {
  CallArgs args = CallArgsFromVp(argc, vp);

  FILE* dumpFile = stdout;
  auto closeFile = mozilla::MakeScopeExit([&dumpFile] {
    if (dumpFile != stdout) {
      fclose(dumpFile);
    }
  });

  if (args.length() > 1) {
    RootedObject callee(cx, &args.callee());
@@ -4204,10 +4209,6 @@ static bool DumpHeap(JSContext* cx, unsigned argc, Value* vp) {

  js::DumpHeap(cx, dumpFile, js::IgnoreNurseryObjects);

  if (dumpFile != stdout) {
    fclose(dumpFile);
  }

  args.rval().setUndefined();
  return true;
}
+3 −4
Original line number Diff line number Diff line
@@ -177,13 +177,12 @@ JSObject* Library::Create(JSContext* cx, HandleValue path,
  PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);

  if (!library) {
#define MAX_ERROR_LEN 1024
    char error[MAX_ERROR_LEN] = "Cannot get error from NSPR.";
    constexpr size_t MaxErrorLength = 1024;
    char error[MaxErrorLength] = "Cannot get error from NSPR.";
    uint32_t errorLen = PR_GetErrorTextLength();
    if (errorLen && errorLen < MAX_ERROR_LEN) {
    if (errorLen && errorLen < MaxErrorLength) {
      PR_GetErrorText(error);
    }
#undef MAX_ERROR_LEN

    if (JS::StringIsASCII(error)) {
      if (JS::UniqueChars pathCharsUTF8 = JS_EncodeStringToUTF8(cx, pathStr)) {
+2 −0
Original line number Diff line number Diff line
@@ -583,6 +583,8 @@ class ScriptSource {
  // A string indicating how this source code was introduced into the system.
  // This is a constant, statically allocated C string, so does not need memory
  // management.
  //
  // TODO: Document the various additional introduction type constants.
  const char* introductionType_ = nullptr;

  // Bytecode offset in caller script that generated this code.  This is
Loading