1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2024-11-18 08:07:31 +02:00

fped/obj.c (generate_items): handle failure to expand package name gracefully

We just use "_" in this case. Before, "expand" returned NULL, which
inst_select_pkg interprets as the global package. This in turn caused
no further packages to be defined and thus active_pkg stayed NULL.
This finally led to a crash in inst_draw.
This commit is contained in:
Werner Almesberger 2011-09-14 20:37:54 -03:00
parent 6dfbb51af9
commit b8f1add539

7
obj.c
View File

@ -1,8 +1,8 @@
/* /*
* obj.c - Object definition model * obj.c - Object definition model
* *
* Written 2009, 2010 by Werner Almesberger * Written 2009-2011 by Werner Almesberger
* Copyright 2009, 2010 by Werner Almesberger * Copyright 2009-2011 by Werner Almesberger
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -285,7 +285,8 @@ static int generate_items(struct frame *frame, struct coord base, int active)
if (frame == frames) { if (frame == frames) {
s = expand(pkg_name, frame); s = expand(pkg_name, frame);
inst_select_pkg(s); /* s is NULL if expansion failed */
inst_select_pkg(s ? s : "_");
free(s); free(s);
} }
inst_begin_active(active && frame == active_frame); inst_begin_active(active && frame == active_frame);