gnuastro-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and


From: Mohammad Akhlaghi
Subject: [task #15567] Converting hh:mm:ss and dd:mm:ss notations to degrees and vice vesa
Date: Mon, 23 Mar 2020 13:50:40 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0

Follow-up Comment #38, task #15567 (project gnuastro):

I got your branch and tried it out, but many corrections are still necessary!
For example Valgrind still reports bad memory usage:


==32624== Invalid read of size 1
==32624==    at 0x4BFEDD: gal_units_extract_decimal (units.c:22)
==32624==    by 0x4BFF81: gal_units_ra_to_decimal (units.c:68)
==32624==    by 0x126DF3: arithmetic_unary_function (arithmetic.c:496)
==32624==    by 0x1465C7: gal_arithmetic (arithmetic.c:2014)
==32624==    by 0x11123B: arithmetic_operator_run (arithmetic.c:595)
==32624==    by 0x111338: arithmetic_reverse_polish (arithmetic.c:641)
==32624==    by 0x111548: arithmetic_operate (arithmetic.c:728)
==32624==    by 0x1126FB: table (table.c:542)
==32624==    by 0x10CBE8: main (main.c:49)
==32624==  Address 0x5ed0529 is 0 bytes after a block of size 9 alloc'd
==32624==    at 0x483977F: malloc (vg_replace_malloc.c:309)
==32624==    by 0x550ABCE: strdup (in /usr/lib/libc-2.31.so)
==32624==    by 0x4BFDB2: gal_units_extract_decimal (units.c:20)
==32624==    by 0x4BFF81: gal_units_ra_to_decimal (units.c:68)
==32624==    by 0x126DF3: arithmetic_unary_function (arithmetic.c:496)
==32624==    by 0x1465C7: gal_arithmetic (arithmetic.c:2014)
==32624==    by 0x11123B: arithmetic_operator_run (arithmetic.c:595)
==32624==    by 0x111338: arithmetic_reverse_polish (arithmetic.c:641)
==32624==    by 0x111548: arithmetic_operate (arithmetic.c:728)
==32624==    by 0x1126FB: table (table.c:542)
==32624==    by 0x10CBE8: main (main.c:49)
==32624== 


Generally, the code still needs a lot of work. Here is a fast list:

* There is no copyright on units.c.
* Don't use `unsigned int', when something relates to sizes (like the `i' or
`n' variables, use `size_t'.
* The delimiter given to `strtok' must be a string (ending in `\0'). It can't
be a pointer to a character! If it doesn't see a `\0' at the end of the
delimiter, `strtok' will continue reading into un-allocated memory.
* When you use the `error' function, there is no more need for a `return 0',
the full program will crash with the given warning. If you don't want it to
crash, you should just give a `0' for the first argument.

Please try it further (and be sure to run it with Valgrind) and fix these
problems, then let me know ;-).

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/task/?15567>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]