src/SDL_hints_c.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 10 Jul 2013 21:57:31 -0700
changeset 7396 a36ab6149a10
parent 7191 75360622e65f
permissions -rw-r--r--
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function Nitz In Function X11_DispatchEvent(_THIS), case SelectionNotify : static void X11_DispatchEvent(_THIS) { // Some Code case SelectionNotify: { //Some Code SDL_bool expect_lf = SDL_FALSE; char *start = NULL; // Initialised with NULL char *scan = (char*)p.data; char *fn; char *uri; int length = 0; while (p.count--) { if (!expect_lf) { if (*scan==0x0D) { expect_lf = SDL_TRUE; } else if(start == NULL) { start = scan; length = 0; } length++; } else { if (*scan==0x0A && length>0) { uri = malloc(length--); memcpy(uri, start, length); // Problem is Here, start is still NULL if control comes to else statement without initialising the start pointer, which is wrong uri[length] = 0; fn = X11_URIToLocal(uri); if (fn) SDL_SendDropFile(fn); free(uri); } expect_lf = SDL_FALSE; start = NULL; } scan++; } } As shown above how start pointer remains NULL, Patch for this issue would be: if (*scan==0x0D) { expect_lf = SDL_TRUE; } if(start == NULL) { start = scan; length = 0; } Just replace else if statement with if.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5556
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
     1
/*
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
     2
 Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
     3
 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
     4
5556
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
     5
 This software is provided 'as-is', without any express or implied
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
     6
 warranty.  In no event will the authors be held liable for any damages
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
     7
 arising from the use of this software.
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
     8
5556
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
     9
 Permission is granted to anyone to use this software for any purpose,
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    10
 including commercial applications, and to alter it and redistribute it
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    11
 freely, subject to the following restrictions:
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 6885
diff changeset
    12
5556
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    13
 1. The origin of this software must not be misrepresented; you must not
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    14
 claim that you wrote the original software. If you use this software
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    15
 in a product, an acknowledgment in the product documentation would be
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    16
 appreciated but is not required.
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    17
 2. Altered source versions must be plainly marked as such, and must not be
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    18
 misrepresented as being the original software.
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    19
 3. This notice may not be removed or altered from any source distribution.
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    20
 */
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    21
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    22
#ifndef _SDL_hints_c_h
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    23
#define _SDL_hints_c_h
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    24
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    25
/**
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    26
 *  \brief  A callback function that is optionally called when a hint changes
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    27
 */
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    28
typedef void (*SDL_HintChangedCb)(const char *name, const char *oldValue, const char *newValue);
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    29
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    30
extern SDL_bool SDL_RegisterHintChangedCb(const char *name, SDL_HintChangedCb hintCb);
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    31
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    32
#endif /* _SDL_hints_c_h */
45a709ef443d * Add missing file SDL_hints_c.h
Tim Angus <tim@blackcompanystudios.co.uk>
parents:
diff changeset
    33
5878
bc68122afbed Added a newline to the end of a file to quiet old versions of GCC.
Ryan C. Gordon <icculus@icculus.org>
parents: 5556
diff changeset
    34
/* vi: set ts=4 sw=4 expandtab: */