author David Keeler <>
Mon, 21 Dec 2015 17:14:41 -0800
changeset 312859 f745c6e024a325921801db0394add38c86f34add
parent 231096 d3025e55dfc3ac40fdedd1344799bd55ff8d2806
child 473816 fba6f974041a3d3c22ef95c44f6e4262e8e5c52f
permissions -rw-r--r--
bug 1234417 - fix a leak in CreateECPublicKey r=rbarnes Before this patch, CreateECPublicKey would create a SECKEYPublicKey allocated on a scoped arena. It would then call CryptoKey::PublicKeyValid, which has the side-effect of importing the key to the internal PKCS#11 slot. When the arena went out of scope, the memory for the key would be released, but the reference to the slot wouldn't, causing a leak. This patch fixes the leak by making the SECKEYPublicKey a ScopedSECKEYPublicKey (which ensures that the type-specific "destructor" SECKEY_DestroyPublicKey is called, which releases the reference to the PKCS#11 slot).

# Any copyright is dedicated to the Public Domain.

# Creates the precomplete file containing the remove and rmdir application
# update instructions which is used to remove files and directories that are no
# longer present in a complete update. The current working directory is used for
# the location to enumerate and to create the precomplete file.

import sys
import os

def get_build_entries(root_path):
    """ Iterates through the root_path, creating a list for each file and
        directory. Excludes any file paths ending with channel-prefs.js.
    rel_file_path_set = set()
    rel_dir_path_set = set()
    for root, dirs, files in os.walk(root_path):
        for file_name in files:
            parent_dir_rel_path = root[len(root_path)+1:]
            rel_path_file = os.path.join(parent_dir_rel_path, file_name)
            rel_path_file = rel_path_file.replace("\\", "/")
            if not (rel_path_file.endswith("channel-prefs.js") or
                    rel_path_file.endswith("update-settings.ini") or
                    rel_path_file.find("distribution/") != -1):

        for dir_name in dirs:
            parent_dir_rel_path = root[len(root_path)+1:]
            rel_path_dir = os.path.join(parent_dir_rel_path, dir_name)
            rel_path_dir = rel_path_dir.replace("\\", "/")+"/"
            if rel_path_dir.find("distribution/") == -1:

    rel_file_path_list = list(rel_file_path_set)
    rel_dir_path_list = list(rel_dir_path_set)

    return rel_file_path_list, rel_dir_path_list

def generate_precomplete(root_path):
    """ Creates the precomplete file containing the remove and rmdir
        application update instructions. The given directory is used
        for the location to enumerate and to create the precomplete file.
    rel_path_precomplete = "precomplete"
    # If inside a Mac bundle use the root of the bundle for the path.
    if os.path.basename(root_path) == "Resources":
        root_path = os.path.abspath(os.path.join(root_path, '../../'))
        rel_path_precomplete = "Contents/Resources/precomplete"

    precomplete_file_path = os.path.join(root_path,rel_path_precomplete)
    # Open the file so it exists before building the list of files and open it
    # in binary mode to prevent OS specific line endings.
    precomplete_file = open(precomplete_file_path, "wb")
    rel_file_path_list, rel_dir_path_list = get_build_entries(root_path)
    for rel_file_path in rel_file_path_list:
        precomplete_file.writelines("remove \""+rel_file_path+"\"\n")

    for rel_dir_path in rel_dir_path_list:
        precomplete_file.writelines("rmdir \""+rel_dir_path+"\"\n")


if __name__ == "__main__":