Re: Found a bug, in gengetopt?

Lorenzo Bettini <[email protected]>
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
Christian Gagneraud wrote:
> Hi all,
> 
> I'm encourted some problem with my .ggo (see attached)
> When i change the args "..." string i get different result, seems that
> there are some memory corruption around there, but don't know if it
> comes from gengetopt or my gcc (Fedora Core 7, x86_64, gcc (GCC) 4.1.2
> 20070502 (Red Hat 4.1.2-12))
> 

Hi there!

I found the bug, and it was due to the fact that values from args_info 
are stored into some local variables before actually examining the args 
value and so some memory corruption came out.

This also allowed me to notice that also other command line options 
specified in the args entry were not taken into consideration (for 
instance --default-optional).

This should now be fixed in this release candidate

http://rap.dsi.unifi.it/~bettini/gengetopt-2.20.tar.gz

however, if you want to try it quickly, this is a simple patch (this 
would only solve your problem with --func-name, not the one with 
--default-optional; for the complete corrected version, you should 
download the 2.20 from the above link).

hope to hear from you soon and
thanks a lot for your feedback
	Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net

_______________________________________________
Help-gengetopt mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gengetopt
gengetopt.patch (text/x-patch, 935 B)
Index: src/gengetopt.cc
===================================================================
RCS file: /home/bettini/work/cvsroot/gengetopt/src/gengetopt.cc,v
retrieving revision 1.44
diff -u -r1.44 gengetopt.cc
--- src/gengetopt.cc	15 Apr 2007 17:11:05 -0000	1.44
+++ src/gengetopt.cc	1 Jul 2007 13:06:31 -0000
@@ -126,11 +126,6 @@
     exit (0);
   }
 
-  cmdline_parser_name = args_info.func_name_arg ;
-  cmdline_filename = args_info.file_name_arg ;
-  c_ext = args_info.c_extension_arg;
-  header_ext = args_info.header_extension_arg;
-
   if ( args_info.input_arg )
     {
       gengetopt_input_filename = strdup (args_info.input_arg);
@@ -157,6 +152,11 @@
     }
   }
 
+  cmdline_parser_name = args_info.func_name_arg ;
+  cmdline_filename = args_info.file_name_arg ;
+  c_ext = args_info.c_extension_arg;
+  header_ext = args_info.header_extension_arg;
+
   if (! check_dependencies()) {
     gengetopt_free();
     return 1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.