Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abe4e70

Browse files
committed
make radload slightly more robust
stops some valgrind warnings
1 parent acf5f51 commit abe4e70

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- fix a crash with SPARC byte-order labq vips images
33
- fix parsing of filenames containing brackets, thanks shilpi230
44
- fix hist_entropy (lovell)
5+
- small fixes to radiance load
56

67
12/1/16 started 8.2.2
78
- changes to ease compiling C++ binding with MSVC [Lovell Fuller]

doc/gtk-doc.make

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ TARGET_DIR=$(HTML_DIR)/$(DOC_MODULE)
2525

2626
SETUP_FILES = \
2727
$(content_files) \
28+
$(expand_content_files) \
2829
$(DOC_MAIN_SGML_FILE) \
2930
$(DOC_MODULE)-sections.txt \
3031
$(DOC_MODULE)-overrides.txt
@@ -86,7 +87,7 @@ GTK_DOC_V_SETUP_0=@echo " DOC Preparing build";
8687

8788
setup-build.stamp:
8889
-$(GTK_DOC_V_SETUP)if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
89-
files=`echo $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types`; \
90+
files=`echo $(SETUP_FILES) $(DOC_MODULE).types`; \
9091
if test "x$$files" != "x" ; then \
9192
for file in $$files ; do \
9293
destdir=`dirname $(abs_builddir)/$$file`; \
@@ -118,7 +119,7 @@ scan-build.stamp: setup-build.stamp $(HFILE_GLOB) $(CFILE_GLOB)
118119
$(GTK_DOC_V_INTROSPECT)if grep -l '^..*$$' $(DOC_MODULE).types > /dev/null 2>&1 ; then \
119120
scanobj_options=""; \
120121
gtkdoc-scangobj 2>&1 --help | grep >/dev/null "\-\-verbose"; \
121-
if test "$(?)" = "0"; then \
122+
if test "$$?" = "0"; then \
122123
if test "x$(V)" = "x1"; then \
123124
scanobj_options="--verbose"; \
124125
fi; \
@@ -162,17 +163,17 @@ GTK_DOC_V_XREF=$(GTK_DOC_V_XREF_$(V))
162163
GTK_DOC_V_XREF_=$(GTK_DOC_V_XREF_$(AM_DEFAULT_VERBOSITY))
163164
GTK_DOC_V_XREF_0=@echo " DOC Fixing cross-references";
164165

165-
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
166+
html-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
166167
$(GTK_DOC_V_HTML)rm -rf html && mkdir html && \
167168
mkhtml_options=""; \
168169
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-verbose"; \
169-
if test "$(?)" = "0"; then \
170+
if test "$$?" = "0"; then \
170171
if test "x$(V)" = "x1"; then \
171172
mkhtml_options="$$mkhtml_options --verbose"; \
172173
fi; \
173174
fi; \
174175
gtkdoc-mkhtml 2>&1 --help | grep >/dev/null "\-\-path"; \
175-
if test "$(?)" = "0"; then \
176+
if test "$$?" = "0"; then \
176177
mkhtml_options="$$mkhtml_options --path=\"$(abs_srcdir)\""; \
177178
fi; \
178179
cd html && gtkdoc-mkhtml $$mkhtml_options $(MKHTML_OPTIONS) $(DOC_MODULE) ../$(DOC_MAIN_SGML_FILE)
@@ -194,11 +195,11 @@ GTK_DOC_V_PDF=$(GTK_DOC_V_PDF_$(V))
194195
GTK_DOC_V_PDF_=$(GTK_DOC_V_PDF_$(AM_DEFAULT_VERBOSITY))
195196
GTK_DOC_V_PDF_0=@echo " DOC Building PDF";
196197

197-
pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files)
198+
pdf-build.stamp: sgml.stamp $(DOC_MAIN_SGML_FILE) $(content_files) $(expand_content_files)
198199
$(GTK_DOC_V_PDF)rm -f $(DOC_MODULE).pdf && \
199200
mkpdf_options=""; \
200201
gtkdoc-mkpdf 2>&1 --help | grep >/dev/null "\-\-verbose"; \
201-
if test "$(?)" = "0"; then \
202+
if test "$$?" = "0"; then \
202203
if test "x$(V)" = "x1"; then \
203204
mkpdf_options="$$mkpdf_options --verbose"; \
204205
fi; \
@@ -223,12 +224,15 @@ clean-local:
223224
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-types" ; then \
224225
rm -f $(DOC_MODULE).types; \
225226
fi
227+
@if echo $(SCAN_OPTIONS) | grep -q "\-\-rebuild-sections" ; then \
228+
rm -f $(DOC_MODULE)-sections.txt; \
229+
fi
226230

227231
distclean-local:
228232
@rm -rf xml html $(REPORT_FILES) $(DOC_MODULE).pdf \
229233
$(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt
230234
@if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
231-
rm -f $(SETUP_FILES) $(expand_content_files) $(DOC_MODULE).types; \
235+
rm -f $(SETUP_FILES) $(DOC_MODULE).types; \
232236
fi
233237

234238
maintainer-clean-local:

doc/libvips-docs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<bookinfo>
1010
<title>VIPS Reference Manual</title>
1111
<releaseinfo>
12-
For VIPS 8.2.2.
12+
For VIPS 8.2.3.
1313
The latest version of this documentation can be found on the
1414
<ulink role="online-location"
1515
url="http://www.vips.ecs.soton.ac.uk/index.php?title=Documentation">VIPS website</ulink>.

libvips/foreign/radiance.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,16 +653,23 @@ buffer_need( Buffer *buffer, int require )
653653
int remaining;
654654

655655
g_assert( require < BUFFER_MARGIN );
656+
g_assert( buffer->length >= 0 );
657+
g_assert( buffer->position >= 0 );
658+
g_assert( buffer->position <= buffer->length );
656659

657660
remaining = buffer->length - buffer->position;
658661
if( remaining < require ) {
659662
size_t len;
660663

661-
memcpy( buffer->text,
664+
/* Areas can overlap.
665+
*/
666+
memmove( buffer->text,
662667
buffer->text + buffer->position, remaining );
663668
buffer->position = 0;
664669
buffer->length = remaining;
665670

671+
g_assert( buffer->length < BUFFER_MARGIN );
672+
666673
len = fread( buffer->text + buffer->length,
667674
1, BUFFER_SIZE, buffer->fp );
668675
buffer->length += len;
@@ -687,6 +694,10 @@ scanline_read_old( Buffer *buffer, COLR *scanline, int width )
687694
{
688695
int rshift;
689696

697+
g_assert( buffer->length >= 0 );
698+
g_assert( buffer->position >= 0 );
699+
g_assert( buffer->position <= buffer->length );
700+
690701
rshift = 0;
691702

692703
while( width > 0 ) {
@@ -728,6 +739,10 @@ scanline_read( Buffer *buffer, COLR *scanline, int width )
728739
{
729740
int i, j;
730741

742+
g_assert( buffer->length >= 0 );
743+
g_assert( buffer->position >= 0 );
744+
g_assert( buffer->position <= buffer->length );
745+
731746
/* Detect old-style scanlines.
732747
*/
733748
if( width < MINELEN ||
@@ -996,8 +1011,10 @@ static const char *colcor_name[3] = {
9961011
static int
9971012
rad2vips_get_header( Read *read, VipsImage *out )
9981013
{
999-
int i, j;
10001014
VipsInterpretation interpretation;
1015+
int width;
1016+
int height;
1017+
int i, j;
10011018

10021019
if( getheader( read->fin, (gethfunc *) rad2vips_process_line, read ) ||
10031020
!fgetsresolu( &read->rs, read->fin ) ) {
@@ -1013,9 +1030,17 @@ rad2vips_get_header( Read *read, VipsImage *out )
10131030
else
10141031
interpretation = VIPS_INTERPRETATION_MULTIBAND;
10151032

1016-
vips_image_init_fields( out,
1017-
scanlen( &read->rs ), numscans( &read->rs ),
1018-
4,
1033+
width = scanlen( &read->rs );
1034+
height = numscans( &read->rs );
1035+
if( width <= 0 ||
1036+
width > VIPS_MAX_COORD ||
1037+
height <= 0 ||
1038+
height > VIPS_MAX_COORD ) {
1039+
vips_error( "rad2vips", "%s", _( "image size out of bounds" ) );
1040+
return( -1 );
1041+
}
1042+
1043+
vips_image_init_fields( out, width, height, 4,
10191044
VIPS_FORMAT_UCHAR, VIPS_CODING_RAD,
10201045
interpretation,
10211046
1, read->aspect );
@@ -1080,6 +1105,7 @@ rad2vips_generate( VipsRegion *or,
10801105
if( scanline_read( read->buffer, buf, or->im->Xsize ) ) {
10811106
vips_error( "rad2vips",
10821107
_( "read error line %d" ), r->top + y );
1108+
VIPS_GATE_STOP( "rad2vips_generate: work" );
10831109
return( -1 );
10841110
}
10851111
}

0 commit comments

Comments
 (0)