We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2964 - Remove NULL check in IMG_LoadTGA_RW function
Summary: Remove NULL check in IMG_LoadTGA_RW function
Status: RESOLVED WONTFIX
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86 Linux
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-28 12:23 UTC by Nitz
Modified: 2015-05-03 02:37 UTC (History)
0 users

See Also:


Attachments
Patch is attached to remove extra NULL check for img (369 bytes, patch)
2015-04-28 12:25 UTC, Nitz
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nitz 2015-04-28 12:23:17 UTC
In IMG_LoadTGA_RW function:

if(img == NULL) {

        error = "Out of memory";

        goto error;

    }


error:
    SDL_RWseek(src, start, RW_SEEK_SET);
    if ( img ) {
        SDL_FreeSurface(img);
    }
    IMG_SetError("%s", error);
    return NULL;

Here again NULL check is applied for img, which is not required as its already checked. So its better to remove this extra code.

Patch is attached.
Comment 1 Nitz 2015-04-28 12:25:27 UTC
Created attachment 2138 [details]
Patch is attached to remove extra NULL check for img
Comment 2 Sam Lantinga 2015-05-03 02:37:04 UTC
This is useful in case anybody adds any additional error conditions in the function. It's not performance critical code so an extra conditional isn't a problem here.

Thanks for the analysis!