|
From: <ai...@us...> - 2013-09-22 02:17:15
|
Revision: 12511
http://sourceforge.net/p/plplot/code/12511
Author: airwin
Date: 2013-09-22 02:17:11 +0000 (Sun, 22 Sep 2013)
Log Message:
-----------
Implement sanity check that pllegend caller does not specify NULL
array pointers for one of the box, line, or symbol arrays when
opt_array contains the relevant bit which would force the array to be
used.
Modified Paths:
--------------
trunk/src/pllegend.c
Modified: trunk/src/pllegend.c
===================================================================
--- trunk/src/pllegend.c 2013-09-21 21:19:22 UTC (rev 12510)
+++ trunk/src/pllegend.c 2013-09-22 02:17:11 UTC (rev 12511)
@@ -576,10 +576,10 @@
legend_width, legend_height, legend_width_ac, legend_height_ac;
PLFLT x_legend_position, y_legend_position, xsign, ysign;
- //PLINT some_boxes = 0, some_lines = 0;
PLINT some_symbols = 0;
PLINT max_symbol_numbers = 0;
- PLINT irow = 0, icolumn = 0;
+ PLINT irow = 0, icolumn = 0;
+ int some_boxes = 0, some_lines = 0;
// Default nrow, ncolumn.
nrow = MAX( nrow, 1 );
@@ -663,17 +663,37 @@
for ( i = 0; i < nlegend; i++ )
{
- //if ( opt_array[i] & PL_LEGEND_COLOR_BOX )
- // some_boxes = 1;
- //if ( opt_array[i] & PL_LEGEND_LINE )
- // some_lines = 1;
+ if ( opt_array[i] & PL_LEGEND_COLOR_BOX )
+ some_boxes = 1;
+ if ( opt_array[i] & PL_LEGEND_LINE )
+ some_lines = 1;
if ( opt_array[i] & PL_LEGEND_SYMBOL )
{
- max_symbol_numbers = MAX( max_symbol_numbers, symbol_numbers[i] );
- some_symbols = 1;
+ if ( symbol_numbers != NULL )
+ max_symbol_numbers = MAX( max_symbol_numbers, symbol_numbers[i] );
+ some_symbols = 1;
}
}
+ // Sanity checks on NULL arrays:
+ if ( some_boxes && ( box_colors == NULL || box_patterns == NULL || box_scales == NULL || box_line_widths == NULL ) )
+ {
+ plabort( "pllegend: all box_* arrays must be defined when the PL_LEGEND_COLOR_BOX bit is set." );
+ return;
+ }
+
+ if ( some_lines && ( line_colors == NULL || line_styles == NULL || line_widths == NULL ) )
+ {
+ plabort( "pllegend: all line_* arrays must be defined when the PL_LEGEND_LINE bit is set." );
+ return;
+ }
+
+ if ( some_symbols && ( symbol_colors == NULL || symbol_scales == NULL || symbol_numbers == NULL ) )
+ {
+ plabort( "pllegend: all symbol_* arrays must be defined when the PL_LEGEND_SYMBOL bit is set." );
+ return;
+ }
+
// Get character height and width in normalized subpage coordinates.
character_height = get_character_or_symbol_height( TRUE );
character_width = character_height;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|