Summary: fc_utf8_validate_rep_len(): "end" might be used
                 Project: Freeciv
            Submitted by: cazfi
            Submitted on: Sat 19 Jan 2013 11:27:39 AM EET
                Category: general
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: Ready For Test
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
        Operating System: None
         Planned Release: 2.3.4, 2.4.0, 2.5.0



When compiling with optimization level -O3 (and related inlining):

../../../src.patched/utility/fc_utf8.c: In function
../../../src.patched/utility/fc_utf8.c:150:17: error: 'end' may be used
uninitialized in this function [-Werror=maybe-uninitialized]
../../../src.patched/utility/fc_utf8.c:132:15: note: 'end' was declared here

Before line 150 fc_utf8_validate_len(...,&end) always gets called and is
supposed to set "end". But it has one way of returning without touching
fc_assert_ret_val(NULL != utf8_string, FALSE);

NULL is not valid input for fc_utf8_validate_rep_len() (it would crash on
strlen()), but compiler does not know that and sees that NULL parameter to
fc_utf8_validate_rep_len() would be passed to fc_utf8_validate_len() causing
fc_assert_ret_val() there to return without touching "end" which is then used

Attached patch simply asserts against NULL in fc_utf8_validate_rep_len() too,
so compiler knows it will never be used deeper in the function.


File Attachments:

Date: Sat 19 Jan 2013 11:27:39 AM EET  Name: NullUtf8StrlcpyFix.patch  Size:
407B   By: cazfi



Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to