[Freeciv-Dev] (PR#10095) handle_game_load() can crash
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10095 >
> [use_less - Tue Sep 14 04:35:54 2004]:
>
> in handle_game_load in gui-gtk-2.0/connectdlg.c, a strrchr is done to
> find the last '/' in the string current_filename, then the title bar is
> changed to the string immediately after that slash. However if there is
> no slash, strrchr will return a null, and gtk_window_set_title() will
> page fault.
>
> Bug seen in win32, where file paths don't always have slashes.
But doesn't win32 use \ as it's separator, so we instead want to do a
strrchr for that?
Regardless, this patch should fix the segfault.
jason
Index: client/gui-gtk-2.0/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/connectdlg.c,v
retrieving revision 1.42
diff -u -r1.42 connectdlg.c
--- client/gui-gtk-2.0/connectdlg.c 13 Sep 2004 08:39:21 -0000 1.42
+++ client/gui-gtk-2.0/connectdlg.c 14 Sep 2004 21:24:22 -0000
@@ -466,7 +466,14 @@
char *buf = current_filename;
buf = strrchr(current_filename, '/');
- gtk_window_set_title(GTK_WINDOW(dialog), ++buf);
+ if (buf) {
+ /* First character after separator. */
+ buf++;
+ } else {
+ /* No separator. */
+ buf = current_filename;
+ }
+ gtk_window_set_title(GTK_WINDOW(dialog), buf);
}
game.nplayers = packet->nplayers;
|
|