bugGNU Astronomy Utilities - Bugs: bug #51603, Lost memory when re-writing option...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #51603: Lost memory when re-writing option value

Submitted by:  Mohammad Akhlaghi <makhlaghi>
Submitted on:  Fri 28 Jul 2017 11:35:58 AM UTC  
 
Category: All GnuastroSeverity: 2 - Minor
Item Group: Addition(s)Status: Postponed
Privacy: PublicAssigned to: None
Open/Closed: Open

Fri 28 Jul 2017 11:35:58 AM UTC, original submission:

On the command-line, the last invocation of a single-valued option is used as its final value.

This is implemented in `gal_options_set_from_key' (of lib/options.c) by simply giving the `set' element the value of `GAL_OPTIONS_NOT_SET'.

This is fine when the memory for the option value is static. But when it is allocated, it will result in the loss of the allocated piece of memory (the pointer will be changed and we loose the address of the allocated memory).

By definition, such allocated pieces of memory aren't usually larger than a few bytes and this bug thus won't cause any problem for the user. But it would be good if we could solve it for things to be clean as possible.

One solution that comes to my mind now is to set another flag in `struct argp_option' (of `bootstrapped/lib/argp.h' which is modified during bootstrapping in bootstrap.conf). This flag can say that memory for this option value is allocated or static. Using this flag, we can then free the space if necessary before setting the `set' flag to `GAL_OPTIONS_NOT_SET'.

But I don't have time to implement this right now and it isn't a major issue. So if you are interested, your help would be very welcome.

Mohammad Akhlaghi <makhlaghi>
Project Administrator

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by makhlaghi (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):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1