Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92db0b82 authored by Elliott Hughes's avatar Elliott Hughes Committed by Steve Kondik
Browse files

Fix a variety of small publicly-reported bugs.

Possible NULL dereference in cmds/bootanimation/BootAnimation.cpp.
https://code.google.com/p/android/issues/detail?id=61556

Missing fclose in core/jni/android_os_Debug.cpp.
https://code.google.com/p/android/issues/detail?id=61546

Bad loop guards in core/jni/android_util_Process.cpp.
https://code.google.com/p/android/issues/detail?id=61557

Assignment to wrong variable in libs/androidfw/AssetManager.cpp.
https://code.google.com/p/android/issues/detail?id=61560

Missing delete[]s in libs/androidfw/ObbFile.cpp.
https://code.google.com/p/android/issues/detail?id=61549

Leaks on error in tools/aapt/Images.cpp.
https://code.google.com/p/android/issues/detail?id=61552

Two missing fclose calls in tools/aapt/Resource.cpp.
https://code.google.com/p/android/issues/detail?id=61553

Missing fclose in tools/aidl/aidl.cpp.
https://code.google.com/p/android/issues/detail?id=61554

Change-Id: I5820f3824e72d07a9acb776cf0af3e7443f5694a
parent 90ae5dac
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -159,8 +159,8 @@ status_t BootAnimation::initTexture(void* buffer, size_t len)
    SkBitmap bitmap;
    SkMemoryStream  stream(buffer, len);
    SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
    codec->setDitherImage(false);
    if (codec) {
        codec->setDitherImage(false);
        codec->decode(&stream, &bitmap,
                #ifdef USE_565
                SkBitmap::kRGB_565_Config,
+5 −1
Original line number Diff line number Diff line
@@ -675,6 +675,7 @@ static jint read_binder_stat(const char* stat)
    // loop until we have the block that represents this process
    do {
        if (fgets(line, 1024, fp) == 0) {
            fclose(fp);
            return -1;
        }
    } while (strncmp(compare, line, len));
@@ -684,13 +685,16 @@ static jint read_binder_stat(const char* stat)

    do {
        if (fgets(line, 1024, fp) == 0) {
            fclose(fp);
            return -1;
        }
    } while (strncmp(compare, line, len));

    // we have the line, now increment the line ptr to the value
    char* ptr = line + len;
    return atoi(ptr);
    jint result = atoi(ptr);
    fclose(fp);
    return result;
}

static jint android_os_Debug_getBinderSentTransactions(JNIEnv *env, jobject clazz)
+7 −7
Original line number Diff line number Diff line
@@ -422,7 +422,7 @@ static int pid_compare(const void* v1, const void* v2)
    return *((const jint*)v1) - *((const jint*)v2);
}

static jlong getFreeMemoryImpl(const char* const sums[], const int sumsLen[], int num)
static jlong getFreeMemoryImpl(const char* const sums[], const size_t sumsLen[], size_t num)
{
    int fd = open("/proc/meminfo", O_RDONLY);

@@ -441,7 +441,7 @@ static jlong getFreeMemoryImpl(const char* const sums[], const int sumsLen[], in
    }
    buffer[len] = 0;

    int numFound = 0;
    size_t numFound = 0;
    jlong mem = 0;

    char* p = buffer;
@@ -473,14 +473,14 @@ static jlong getFreeMemoryImpl(const char* const sums[], const int sumsLen[], in
static jlong android_os_Process_getFreeMemory(JNIEnv* env, jobject clazz)
{
    static const char* const sums[] = { "MemFree:", "Cached:", NULL };
    static const int sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 };
    static const size_t sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 };
    return getFreeMemoryImpl(sums, sumsLen, 2);
}

static jlong android_os_Process_getTotalMemory(JNIEnv* env, jobject clazz)
{
    static const char* const sums[] = { "MemTotal:", NULL };
    static const int sumsLen[] = { strlen("MemTotal:"), 0 };
    static const size_t sumsLen[] = { strlen("MemTotal:"), 0 };
    return getFreeMemoryImpl(sums, sumsLen, 1);
}

@@ -745,7 +745,7 @@ jboolean android_os_Process_parseProcLineArray(JNIEnv* env, jobject clazz,

        jsize end = -1;
        if ((mode&PROC_PARENS) != 0) {
            while (buffer[i] != ')' && i < endIndex) {
            while (i < endIndex && buffer[i] != ')') {
                i++;
            }
            end = i;
@@ -757,7 +757,7 @@ jboolean android_os_Process_parseProcLineArray(JNIEnv* env, jobject clazz,
            end = i;
            i++;
        }
        while (buffer[i] != term && i < endIndex) {
        while (i < endIndex && buffer[i] != term) {
            i++;
        }
        if (end < 0) {
@@ -767,7 +767,7 @@ jboolean android_os_Process_parseProcLineArray(JNIEnv* env, jobject clazz,
        if (i < endIndex) {
            i++;
            if ((mode&PROC_COMBINE) != 0) {
                while (buffer[i] == term && i < endIndex) {
                while (i < endIndex && buffer[i] == term) {
                    i++;
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ bool ObbFile::parseObbFile(int fd)
    {
        lseek64(fd, fileLength - kFooterTagSize, SEEK_SET);

        char *footer = new char[kFooterTagSize];
        char footer[kFooterTagSize];
        actual = TEMP_FAILURE_RETRY(read(fd, footer, kFooterTagSize));
        if (actual != kFooterTagSize) {
            ALOGW("couldn't read footer signature: %s\n", strerror(errno));
+10 −11
Original line number Diff line number Diff line
@@ -450,10 +450,11 @@ static status_t do_9patch(const char* imageName, image_info* image)

    int maxSizeXDivs = W * sizeof(int32_t);
    int maxSizeYDivs = H * sizeof(int32_t);
    int32_t* xDivs = (int32_t*) malloc(maxSizeXDivs);
    int32_t* yDivs = (int32_t*) malloc(maxSizeYDivs);
    int32_t* xDivs = image->info9Patch.xDivs = (int32_t*) malloc(maxSizeXDivs);
    int32_t* yDivs = image->info9Patch.yDivs = (int32_t*) malloc(maxSizeYDivs);
    uint8_t numXDivs = 0;
    uint8_t numYDivs = 0;

    int8_t numColors;
    int numRows;
    int numCols;
@@ -508,6 +509,10 @@ static status_t do_9patch(const char* imageName, image_info* image)
        goto getout;
    }

    // Copy patch size data into image...
    image->info9Patch.numXDivs = numXDivs;
    image->info9Patch.numYDivs = numYDivs;

    // Find left and right of padding area...
    if (get_horizontal_ticks(image->rows[H-1], W, transparent, false, &image->info9Patch.paddingLeft,
                             &image->info9Patch.paddingRight, &errorMsg, NULL, false) != NO_ERROR) {
@@ -543,12 +548,6 @@ static status_t do_9patch(const char* imageName, image_info* image)
                image->layoutBoundsRight, image->layoutBoundsBottom));
    }

    // Copy patch data into image
    image->info9Patch.numXDivs = numXDivs;
    image->info9Patch.numYDivs = numYDivs;
    image->info9Patch.xDivs = xDivs;
    image->info9Patch.yDivs = yDivs;

    // If padding is not yet specified, take values from size.
    if (image->info9Patch.paddingLeft < 0) {
        image->info9Patch.paddingLeft = xDivs[0];
Loading