Fix multiple potential null pointer dereferencess

GCC's optimizer thinks all of these _will_ fail at some point

Change-Id: I287eeb574162a5d3b3347654d25aa1f53e9f5563
This commit is contained in:
Solomon Peachy 2020-10-27 11:14:23 -04:00
parent 621e363e70
commit a605cdf700
8 changed files with 160 additions and 88 deletions

View file

@ -219,7 +219,9 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
{
int original_x, original_y;
skin_viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), viewport->data);
char *viewport_label = SKINOFFSETTOPTR(get_skin_buffer(wps.data), skin_viewport->label);
char *viewport_label = NULL;
if (skin_viewport)
viewport_label = SKINOFFSETTOPTR(get_skin_buffer(wps.data), skin_viewport->label);
if (viewport->children == 0 || !viewport_label ||
(skin_viewport->label && strcmp(label, viewport_label))
)
@ -254,11 +256,15 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
while (imglist)
{
struct wps_token *token = SKINOFFSETTOPTR(get_skin_buffer(wps.data), imglist->token);
struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(wps.data), token->value.data);
struct gui_img *img = NULL;
if (token)
img = SKINOFFSETTOPTR(get_skin_buffer(wps.data), token->value.data);
if (img)
img->display = -1;
imglist = SKINOFFSETTOPTR(get_skin_buffer(wps.data), imglist->next);
}
struct skin_element** children = SKINOFFSETTOPTR(get_skin_buffer(wps.data), viewport->children);
if (children && *children)
skin_render_viewport(SKINOFFSETTOPTR(get_skin_buffer(wps.data), (intptr_t)children[0]),
&wps, skin_viewport, SKIN_REFRESH_ALL);
wps_display_images(&wps, &skin_viewport->vp);
@ -278,4 +284,3 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list)
current_drawing_line = list->selected_item;
return true;
}

View file

@ -390,7 +390,10 @@ void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
while (list)
{
struct wps_token *token = SKINOFFSETTOPTR(get_skin_buffer(data), list->token);
struct gui_img *img = (struct gui_img*)SKINOFFSETTOPTR(get_skin_buffer(data), token->value.data);
struct gui_img *img = NULL;
if (token)
img = (struct gui_img*)SKINOFFSETTOPTR(get_skin_buffer(data), token->value.data);
if (img) {
if (img->using_preloaded_icons && img->display >= 0)
{
screen_put_icon(display, img->x, img->y, img->display);
@ -402,6 +405,7 @@ void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
wps_draw_image(gwps, img, img->display, vp);
}
}
}
list = SKINOFFSETTOPTR(get_skin_buffer(data), list->next);
}
#ifdef HAVE_ALBUMART

View file

@ -183,13 +183,16 @@ void *skin_find_item(const char *label, enum skin_find_what what,
{
bool skip = false;
struct wps_token *token = NULL;
itemlabel = NULL;
if (!isvplist)
token = SKINOFFSETTOPTR(databuf, list.linkedlist->token);
if (token)
switch (what)
{
case SKIN_FIND_UIVP:
case SKIN_FIND_VP:
ret = SKINOFFSETTOPTR(databuf, list.vplist->data);
if (!ret) break;
if (((struct skin_viewport *)ret)->label == VP_DEFAULT_LABEL)
itemlabel = VP_DEFAULT_LABEL_STRING;
else
@ -199,10 +202,12 @@ void *skin_find_item(const char *label, enum skin_find_what what,
break;
case SKIN_FIND_IMAGE:
ret = SKINOFFSETTOPTR(databuf, token->value.data);
if (!ret) break;
itemlabel = SKINOFFSETTOPTR(databuf, ((struct gui_img *)ret)->label);
break;
#ifdef HAVE_TOUCHSCREEN
case SKIN_FIND_TOUCHREGION:
if (!ret) break;
ret = SKINOFFSETTOPTR(databuf, token->value.data);
itemlabel = SKINOFFSETTOPTR(databuf, ((struct touchregion *)ret)->label);
break;
@ -210,6 +215,7 @@ void *skin_find_item(const char *label, enum skin_find_what what,
#ifdef HAVE_SKIN_VARIABLES
case SKIN_VARIABLE:
ret = SKINOFFSETTOPTR(databuf, token->value.data);
if (!ret) break;
itemlabel = SKINOFFSETTOPTR(databuf, ((struct skin_var *)ret)->label);
break;
#endif
@ -1708,23 +1714,30 @@ void skin_data_free_buflib_allocs(struct wps_data *wps_data)
{
if (wps_data->wps_loaded)
skin_buffer = get_skin_buffer(wps_data);
if (!skin_buffer)
return;
#ifndef __PCTOOL__
struct skin_token_list *list = SKINOFFSETTOPTR(skin_buffer, wps_data->images);
int *font_ids = SKINOFFSETTOPTR(skin_buffer, wps_data->font_ids);
while (list)
{
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, list->token);
struct gui_img *img = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (img->buflib_handle > 0)
struct gui_img *img = NULL;
if (token)
img = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (img && img->buflib_handle > 0)
{
struct skin_token_list *imglist = SKINOFFSETTOPTR(skin_buffer, list->next);
core_free(img->buflib_handle);
core_free(img->buflib_handle);
while (imglist)
{
struct wps_token *freetoken = SKINOFFSETTOPTR(skin_buffer, imglist->token);
struct gui_img *freeimg = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, freetoken->value.data);
if (img->buflib_handle == freeimg->buflib_handle)
struct gui_img *freeimg = NULL;
if (freetoken)
freeimg = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, freetoken->value.data);
if (freeimg && img->buflib_handle == freeimg->buflib_handle)
freeimg->buflib_handle = -1;
imglist = SKINOFFSETTOPTR(skin_buffer, imglist->next);
}
@ -1885,8 +1898,10 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
while (list)
{
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, list->token);
if (!token) goto skip;
struct gui_img *img = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!img->loaded)
if (img && !img->loaded)
{
if (img->using_preloaded_icons)
{
@ -1901,21 +1916,23 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
handle = load_skin_bmp(wps_data, &img->bm, bmpdir);
img->buflib_handle = handle;
img->loaded = img->buflib_handle >= 0;
if (img->loaded)
{
struct skin_token_list *imglist = SKINOFFSETTOPTR(skin_buffer, list->next);
img->subimage_height = img->bm.height / img->num_subimages;
while (imglist)
{
token = SKINOFFSETTOPTR(skin_buffer, imglist->token);
if (token) {
img = (struct gui_img*)SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!strcmp(path, img->bm.data))
if (img && !strcmp(path, img->bm.data))
{
img->loaded = true;
img->buflib_handle = handle;
img->subimage_height = img->bm.height / img->num_subimages;
}
}
imglist = SKINOFFSETTOPTR(skin_buffer, imglist->next);
}
}
@ -1923,6 +1940,7 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
retval = false;
}
}
skip:
list = SKINOFFSETTOPTR(skin_buffer, list->next);
}
@ -1947,6 +1965,7 @@ static bool skin_load_fonts(struct wps_data *data)
/* first, find the viewports that have a non-sys/ui-font font */
struct skin_viewport *skin_vp =
SKINOFFSETTOPTR(skin_buffer, vp_list->data);
if (!skin_vp) continue;
struct viewport *vp = &skin_vp->vp;
font_id = skin_vp->parsed_fontid;
@ -2507,9 +2526,10 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
while (regions)
{
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, regions->token);
struct touchregion *r = SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (r->action != ACTION_TOUCH_SCROLLBAR &&
struct touchregion *r = NULL;
if (token)
r = SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (r && r->action != ACTION_TOUCH_SCROLLBAR &&
r->action != ACTION_TOUCH_VOLUME)
{
user_touch_region_found = true;

View file

@ -96,7 +96,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
struct skin_element *element, struct skin_viewport* skin_vp)
{
struct wps_token *token = (struct wps_token *)SKINOFFSETTOPTR(skin_buffer, element->data);
if (!token) return false;
struct viewport *vp = &skin_vp->vp;
struct wps_data *data = gwps->data;
bool do_refresh = (element->tag->flags & info->refresh_type) > 0;
@ -107,7 +107,9 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
case SKIN_TOKEN_VIEWPORT_FGCOLOUR:
{
struct viewport_colour *col = SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!col) return false;
struct viewport *vp = SKINOFFSETTOPTR(skin_buffer, col->vp);
if (!vp) return false;
vp->fg_pattern = col->colour;
skin_vp->fgbg_changed = true;
}
@ -115,7 +117,9 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
case SKIN_TOKEN_VIEWPORT_BGCOLOUR:
{
struct viewport_colour *col = SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!col) return false;
struct viewport *vp = SKINOFFSETTOPTR(skin_buffer, col->vp);
if (!vp) return false;
vp->bg_pattern = col->colour;
skin_vp->fgbg_changed = true;
}
@ -124,6 +128,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
{
struct line_desc *data = SKINOFFSETTOPTR(skin_buffer, token->value.data);
struct line_desc *linedes = &info->line_desc;
if (!data || !linedes) return false;
/* gradient colors are handled with a separate tag
* (SKIN_TOKEN_VIEWPORT_GRADIENT_SETUP, see below). since it may
* come before the text style tag color fields need to be preserved */
@ -147,6 +152,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
{
struct gradient_config *cfg = SKINOFFSETTOPTR(skin_buffer, token->value.data);
struct line_desc *linedes = &info->line_desc;
if (!cfg || !linedes) return false;
linedes->text_color = cfg->text;
linedes->line_color = cfg->start;
linedes->line_end_color = cfg->end;
@ -162,6 +168,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
{
struct skin_viewport *skinvp = SKINOFFSETTOPTR(skin_buffer, viewport->data);
if (skinvp) {
char *vplabel = SKINOFFSETTOPTR(skin_buffer, skinvp->label);
if (skinvp->label == VP_DEFAULT_LABEL)
vplabel = VP_DEFAULT_LABEL_STRING;
@ -174,6 +181,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
}
skinvp->hidden_flags = temp;
}
}
viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next);
}
}
@ -195,6 +203,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
{
struct draw_rectangle *rect =
SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!rect) break;
#ifdef HAVE_LCD_COLOR
if (rect->start_colour != rect->end_colour &&
gwps->display->screen_type == SCREEN_MAIN)
@ -245,6 +254,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
case SKIN_TOKEN_IMAGE_DISPLAY_9SEGMENT:
{
struct image_display *id = SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!id) break;
const char* label = SKINOFFSETTOPTR(skin_buffer, id->label);
struct gui_img *img = skin_find_item(label,SKIN_FIND_IMAGE, data);
if (img && img->loaded)
@ -313,7 +323,6 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
skin_render_playlistviewer(SKINOFFSETTOPTR(skin_buffer, token->value.data), gwps,
info->skin_vp, info->refresh_type);
break;
#ifdef HAVE_SKIN_VARIABLES
case SKIN_TOKEN_VAR_SET:
{
@ -374,19 +383,21 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch,
{
do_tags_in_hidden_conditional(get_child(child->children, i), info);
}
child = SKINOFFSETTOPTR(skin_buffer, child->next);
continue;
goto skip;
}
else if (child->type != TAG || !SKINOFFSETTOPTR(skin_buffer, child->data))
{
child = SKINOFFSETTOPTR(skin_buffer, child->next);
continue;
goto skip;
}
token = (struct wps_token *)SKINOFFSETTOPTR(skin_buffer, child->data);
/* clear all pictures in the conditional and nested ones */
if (token->type == SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY)
{
struct image_display *id = SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (!id) goto skip;
struct gui_img *img = skin_find_item(SKINOFFSETTOPTR(skin_buffer, id->label),
SKIN_FIND_IMAGE, data);
clear_image_pos(gwps, img);
@ -404,6 +415,7 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch,
viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next))
{
struct skin_viewport *skin_viewport = SKINOFFSETTOPTR(skin_buffer, viewport->data);
if (!skin_viewport) continue;
char *vplabel = SKINOFFSETTOPTR(skin_buffer, skin_viewport->label);
if (skin_viewport->label == VP_DEFAULT_LABEL)
vplabel = VP_DEFAULT_LABEL_STRING;
@ -451,6 +463,7 @@ static void do_tags_in_hidden_conditional(struct skin_element* branch,
playback_current_aa_hid(data->playback_aa_slot), true);
}
#endif
skip:
child = SKINOFFSETTOPTR(skin_buffer, child->next);
}
}
@ -517,6 +530,7 @@ static bool skin_render_line(struct skin_element* line, struct skin_draw_info *i
{
case CONDITIONAL:
conditional = SKINOFFSETTOPTR(skin_buffer, child->data);
if (!conditional) break;
last_value = conditional->last_value;
value = evaluate_conditional(info->gwps, info->offset,
conditional, child->children_count);
@ -623,6 +637,7 @@ static int get_subline_timeout(struct gui_wps *gwps, struct skin_element* line)
element->tag->type == SKIN_TOKEN_SUBLINE_TIMEOUT )
{
token = SKINOFFSETTOPTR(skin_buffer, element->data);
if (token)
return token->value.i;
}
else if (element->type == CONDITIONAL)
@ -726,8 +741,11 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps,
while (imglist)
{
struct wps_token *token = SKINOFFSETTOPTR(skin_buffer, imglist->token);
if (token) {
struct gui_img *img = (struct gui_img *)SKINOFFSETTOPTR(skin_buffer, token->value.data);
if (img)
img->display = -1;
}
imglist = SKINOFFSETTOPTR(skin_buffer, imglist->next);
}
@ -756,7 +774,6 @@ void skin_render_viewport(struct skin_element* viewport, struct gui_wps *gwps,
align->center = NULL;
align->right = NULL;
if (line->type == LINE_ALTERNATOR)
func = skin_render_alternator;
else if (line->type == LINE)
@ -819,9 +836,10 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode)
display->clear_viewport();
}
}
viewport = SKINOFFSETTOPTR(skin_buffer, data->tree);
if (!viewport) return;
skin_viewport = SKINOFFSETTOPTR(skin_buffer, viewport->data);
if (!skin_viewport) return;
label = SKINOFFSETTOPTR(skin_buffer, skin_viewport->label);
if (skin_viewport->label == VP_DEFAULT_LABEL)
label = VP_DEFAULT_LABEL_STRING;
@ -833,8 +851,10 @@ void skin_render(struct gui_wps *gwps, unsigned refresh_mode)
viewport;
viewport = SKINOFFSETTOPTR(skin_buffer, viewport->next))
{
/* SETUP */
skin_viewport = SKINOFFSETTOPTR(skin_buffer, viewport->data);
if (!skin_viewport) continue;
unsigned vp_refresh_mode = refresh_mode;
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
if (skin_viewport->output_to_backdrop_buffer)

View file

@ -610,10 +610,13 @@ static const char* NOINLINE get_lif_token_value(struct gui_wps *gwps,
char temp_buf[MAX_PATH];
const char *outb;
struct skin_element *element = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), lif->operand.data.code);
if (!element) return NULL;
struct wps_token *token = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), element->data);
b = lif->num_options;
outb = get_token_value(gwps, token, offset, temp_buf,
sizeof(temp_buf), &b);
if (b == -1 && liftoken->type != SKIN_TOKEN_VOLUME)
{
if (!out_text || !outb)
@ -666,6 +669,8 @@ const char *get_token_value(struct gui_wps *gwps,
{
if (!gwps)
return NULL;
if (!token)
return NULL;
struct wps_data *data = gwps->data;
struct wps_state *state = skin_get_global_state();
@ -734,6 +739,7 @@ const char *get_token_value(struct gui_wps *gwps,
char *skinbuffer = get_skin_buffer(data);
struct skin_element *element =
SKINOFFSETTOPTR(skinbuffer, token->value.data);
if (!element || !element->params) return NULL;
struct skin_tag_parameter* params =
SKINOFFSETTOPTR(skinbuffer, element->params);
struct skin_tag_parameter* thistag;
@ -742,6 +748,7 @@ const char *get_token_value(struct gui_wps *gwps,
thistag = &params[i];
struct skin_element *tokenelement =
SKINOFFSETTOPTR(skinbuffer, thistag->data.code);
if (!tokenelement) return NULL;
out_text = get_token_value(gwps,
SKINOFFSETTOPTR(skinbuffer, tokenelement->data),
offset, buf, buf_size, intval);
@ -753,9 +760,11 @@ const char *get_token_value(struct gui_wps *gwps,
return truecount ? "true" : NULL;
}
break;
case SKIN_TOKEN_SUBSTRING:
{
struct substring *ss = SKINOFFSETTOPTR(get_skin_buffer(data), token->value.data);
if (!ss) return NULL;
const char *token_val = get_token_value(gwps,
SKINOFFSETTOPTR(get_skin_buffer(data), ss->token), offset,
buf, buf_size, intval);
@ -821,6 +830,7 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_LIST_ITEM_TEXT:
{
struct listitem *li = (struct listitem *)SKINOFFSETTOPTR(get_skin_buffer(data), token->value.data);
if (!li) return NULL;
return skinlist_get_item_text(li->offset, li->wrap, buf, buf_size);
}
case SKIN_TOKEN_LIST_ITEM_ROW:
@ -843,6 +853,7 @@ const char *get_token_value(struct gui_wps *gwps,
case SKIN_TOKEN_LIST_ITEM_ICON:
{
struct listitem *li = (struct listitem *)SKINOFFSETTOPTR(get_skin_buffer(data), token->value.data);
if (!li) return NULL;
int icon = skinlist_get_item_icon(li->offset, li->wrap);
if (intval)
*intval = icon;
@ -905,6 +916,7 @@ const char *get_token_value(struct gui_wps *gwps,
if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
{
struct skin_albumart *aa = SKINOFFSETTOPTR(get_skin_buffer(data), data->albumart);
if (!aa) return NULL;
struct dim dim = {aa->width, aa->height};
handle = radio_get_art_hid(&dim);
}
@ -1336,13 +1348,13 @@ const char *get_token_value(struct gui_wps *gwps,
token->value.i))
return "v";
return NULL;
case SKIN_TOKEN_LASTTOUCH:
{
#ifdef HAVE_TOUCHSCREEN
unsigned int last_touch = touchscreen_last_touch();
char *skin_base = get_skin_buffer(data);
struct touchregion_lastpress *data = SKINOFFSETTOPTR(skin_base, token->value.data);
if (!data) return NULL;
struct touchregion *region = SKINOFFSETTOPTR(skin_base, data->region);
if (region)
last_touch = region->last_press;
@ -1669,10 +1681,8 @@ const char *get_token_value(struct gui_wps *gwps,
}
return NULL;
#endif
default:
return NULL;
}
}

View file

@ -92,7 +92,8 @@ int sb_postproccess(enum screen_type screen, struct wps_data *data)
* hence .sbs's without any other vps are unsupported*/
struct skin_viewport *vp = skin_find_item(VP_DEFAULT_LABEL_STRING, SKIN_FIND_VP, data);
struct skin_element *tree = SKINOFFSETTOPTR(get_skin_buffer(data), data->tree);
struct skin_element *next_vp = SKINOFFSETTOPTR(get_skin_buffer(data), tree->next);
struct skin_element *next_vp = NULL;
if (tree) next_vp = SKINOFFSETTOPTR(get_skin_buffer(data), tree->next);
if (vp)
{
@ -132,9 +133,12 @@ struct viewport *sb_skin_get_info_vp(enum screen_type screen)
viewportmanager_theme_enable(screen, false, NULL);
viewportmanager_theme_undo(screen, true);
}
label = SKINOFFSETTOPTR(get_skin_buffer(data), infovp_label[screen]);
if (infovp_label[screen] == VP_DEFAULT_LABEL)
label = VP_DEFAULT_LABEL_STRING;
else
label = SKINOFFSETTOPTR(get_skin_buffer(data), infovp_label[screen]);
if (!label)
return NULL;
vp = skin_find_item(label, SKIN_FIND_UIVP, data);
if (!vp)
return NULL;

View file

@ -623,6 +623,7 @@ struct pgn_game_node* pgn_list_games(const char* filename){
/* a new game header is found */
if (line_buffer[0] == '['){
temp_node = (struct pgn_game_node *)pl_malloc(sizeof size_node);
if (!temp_node) return NULL;
temp_node->next_node = NULL;
if (curr_node == NULL) {
first_game = curr_node = temp_node;
@ -773,10 +774,12 @@ void pgn_parse_game(const char* filename,
*/
if (first_ply != NULL){
temp_ply = (struct pgn_ply_node *)pl_malloc(sizeof size_ply);
if (temp_ply) {
temp_ply->player = neutral;
temp_ply->prev_node = curr_node;
curr_node->next_node = temp_ply;
}
}
selected_game->first_ply = first_ply;
rb->close(fhandler);
@ -793,6 +796,7 @@ struct pgn_game_node* pgn_init_game(void){
/* create an "end of game" dummy ply and assign defaults */
ply = (struct pgn_ply_node *)pl_malloc(sizeof ply_size);
if (!ply) return NULL;
ply->player = neutral;
ply->pgn_text[0] = '\0';
ply->prev_node = NULL;
@ -800,6 +804,8 @@ struct pgn_game_node* pgn_init_game(void){
/* create the game and assign defaults */
game = (struct pgn_game_node *)pl_malloc(sizeof game_size);
if (!game) return NULL;
game->game_number = 0;
rb->strcpy(game->white_player,"Player");
rb->strcpy(game->black_player,"GnuChess");
@ -823,6 +829,7 @@ void pgn_append_ply(struct pgn_game_node* game,
struct pgn_ply_node ply_size, *ply, *temp;
ply = (struct pgn_ply_node *)pl_malloc(sizeof ply_size);
if (!ply) return;
ply->player = ply_player;
ply->column_from = move_buffer[0] - 'a';
ply->row_from = move_buffer[1] - '1';
@ -847,6 +854,7 @@ void pgn_append_ply(struct pgn_game_node* game,
} else {
temp->prev_node->next_node = ply;
}
temp->prev_node = ply;
}

View file

@ -637,12 +637,13 @@ enum plugin_status plugin_start(const void *parameter) {
draw_screen = false;
}
switch(cur_player) {
case BLACK:
cur_strategy = black_strategy;
break;
case WHITE:
cur_strategy = white_strategy;
break;
case BLACK:
default:
cur_strategy = black_strategy;
break;
}
if(cur_strategy->is_robot && !game_finished) {