bugFreeciv - Bugs: bug #19104, [traits] in sanity_check_size()...

 
 
Show feedback again

bug #19104: [traits] in sanity_check_size() [mem.c::61]: Warning: malloc with size 0

Submitted by:  Jacob Nevins <jtn>
Submitted on:  Sat 03 Dec 2011 06:11:10 PM UTC  
 
Category: generalSeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Assigned to: Jacob Nevins <jtn>Open/Closed: Closed
Release: Operating System: Any
Planned Release: 2.5.0

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 06 Dec 2011 10:16:36 PM UTC, SVN revision 20636:

Fix off-by-one when allocating space for nation traits.

See gna bug #19104.

(Browse SVN revision 20636)

Jacob Nevins <jtn>
Project AdministratorIn charge of this item.
Sat 03 Dec 2011 06:31:05 PM UTC, comment #1:

On second thoughts, let's use fc_calloc(). We don't need the zeroing, but otherwise it's tidier.

(file #14641)

Jacob Nevins <jtn>
Project AdministratorIn charge of this item.
Sat 03 Dec 2011 06:11:10 PM UTC, original submission:

Running a trunk server with "-d 3" gives a bunch of the quoted message.

This is due to an off-by-one when malloc'ing space for nation traits (there's currently one, "placeholder", but we malloc k*trait_max() where trait_max() is 0).

This presumably doesn't lead to segfaults because fc_real_malloc() suppresses the allowed/common C behaviour of returning NULL from malloc(0) (although it's still malloc'ing only 1 char, not sizeof(int)).

Jacob Nevins <jtn>
Project AdministratorIn charge of this item.

 

(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #14641:  trunk-trait-nation-alloc-bis.diff added by jtn (744B - text/x-patch - trunk r20621 -- use fc_calloc())
file #14640:  trunk-trait-nation-alloc.diff added by jtn (747B - text/x-patch - trunk r20621)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jtn (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 06 Dec 2011 10:18:37 PM UTCjtnStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Sat 03 Dec 2011 06:31:05 PM UTCjtnAttached File-=>Added trunk-trait-nation-alloc-bis.diff, #14641
    Sat 03 Dec 2011 06:12:06 PM UTCjtnAttached File-=>Added trunk-trait-nation-alloc.diff, #14640
      StatusIn Progress=>Ready For Test
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup