return the number of bytes that have been read from the file.
2007-07-05 Sven Neumann <sven@gimp.org> * app/xcf/xcf-read.c (xcf_read_int32) (xcf_read_int8): return the number of bytes that have been read from the file. * app/xcf/xcf-load.c (xcf_load_prop): return FALSE when reading fails. svn path=/trunk/; revision=22873
This commit is contained in:

committed by
Sven Neumann

parent
792de8539e
commit
4512af8de1
@ -1,3 +1,10 @@
|
|||||||
|
2007-07-05 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/xcf/xcf-read.c (xcf_read_int32) (xcf_read_int8): return the
|
||||||
|
number of bytes that have been read from the file.
|
||||||
|
|
||||||
|
* app/xcf/xcf-load.c (xcf_load_prop): return FALSE when reading fails.
|
||||||
|
|
||||||
2007-07-05 Sven Neumann <sven@gimp.org>
|
2007-07-05 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* tools/pdbgen/pdb.pl (arg_parse): allow the use of constants when
|
* tools/pdbgen/pdb.pl (arg_parse): allow the use of constants when
|
||||||
|
@ -297,7 +297,7 @@ xcf_load_image_props (XcfInfo *info,
|
|||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (!xcf_load_prop (info, &prop_type, &prop_size))
|
if (! xcf_load_prop (info, &prop_type, &prop_size))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
switch (prop_type)
|
switch (prop_type)
|
||||||
@ -381,8 +381,10 @@ xcf_load_image_props (XcfInfo *info,
|
|||||||
nguides = prop_size / (4 + 1);
|
nguides = prop_size / (4 + 1);
|
||||||
for (i = 0; i < nguides; i++)
|
for (i = 0; i < nguides; i++)
|
||||||
{
|
{
|
||||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) &position, 1);
|
info->cp += xcf_read_int32 (info->fp,
|
||||||
info->cp += xcf_read_int8 (info->fp, (guint8 *) &orientation, 1);
|
(guint32 *) &position, 1);
|
||||||
|
info->cp += xcf_read_int8 (info->fp,
|
||||||
|
(guint8 *) &orientation, 1);
|
||||||
|
|
||||||
/* skip -1 guides from old XCFs */
|
/* skip -1 guides from old XCFs */
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
@ -617,7 +619,7 @@ xcf_load_layer_props (XcfInfo *info,
|
|||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (!xcf_load_prop (info, &prop_type, &prop_size))
|
if (! xcf_load_prop (info, &prop_type, &prop_size))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
switch (prop_type)
|
switch (prop_type)
|
||||||
@ -715,6 +717,7 @@ xcf_load_layer_props (XcfInfo *info,
|
|||||||
gimp_item_parasite_attach (GIMP_ITEM (layer), p);
|
gimp_item_parasite_attach (GIMP_ITEM (layer), p);
|
||||||
gimp_parasite_free (p);
|
gimp_parasite_free (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->cp - base != prop_size)
|
if (info->cp - base != prop_size)
|
||||||
gimp_message (info->gimp, G_OBJECT (info->progress),
|
gimp_message (info->gimp, G_OBJECT (info->progress),
|
||||||
GIMP_MESSAGE_WARNING,
|
GIMP_MESSAGE_WARNING,
|
||||||
@ -763,7 +766,7 @@ xcf_load_channel_props (XcfInfo *info,
|
|||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
if (!xcf_load_prop (info, &prop_type, &prop_size))
|
if (! xcf_load_prop (info, &prop_type, &prop_size))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
switch (prop_type)
|
switch (prop_type)
|
||||||
@ -857,6 +860,7 @@ xcf_load_channel_props (XcfInfo *info,
|
|||||||
gimp_item_parasite_attach (GIMP_ITEM (*channel), p);
|
gimp_item_parasite_attach (GIMP_ITEM (*channel), p);
|
||||||
gimp_parasite_free (p);
|
gimp_parasite_free (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->cp - base != prop_size)
|
if (info->cp - base != prop_size)
|
||||||
gimp_message (info->gimp, G_OBJECT (info->progress),
|
gimp_message (info->gimp, G_OBJECT (info->progress),
|
||||||
GIMP_MESSAGE_WARNING,
|
GIMP_MESSAGE_WARNING,
|
||||||
@ -896,8 +900,16 @@ xcf_load_prop (XcfInfo *info,
|
|||||||
PropType *prop_type,
|
PropType *prop_type,
|
||||||
guint32 *prop_size)
|
guint32 *prop_size)
|
||||||
{
|
{
|
||||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) prop_type, 1);
|
if (G_UNLIKELY (xcf_read_int32 (info->fp, (guint32 *) prop_type, 1) != 4))
|
||||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) prop_size, 1);
|
return FALSE;
|
||||||
|
|
||||||
|
info->cp += 4;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (xcf_read_int32 (info->fp, (guint32 *) prop_size, 1) != 4))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
info->cp += 4;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ xcf_read_int32 (FILE *fp,
|
|||||||
guint32 *data,
|
guint32 *data,
|
||||||
gint count)
|
gint count)
|
||||||
{
|
{
|
||||||
guint total = count;
|
guint total = 0;
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
xcf_read_int8 (fp, (guint8 *) data, count * 4);
|
total += xcf_read_int8 (fp, (guint8 *) data, count * 4);
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
@ -47,7 +47,7 @@ xcf_read_int32 (FILE *fp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return total * 4;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
@ -63,15 +63,17 @@ xcf_read_int8 (FILE *fp,
|
|||||||
guint8 *data,
|
guint8 *data,
|
||||||
gint count)
|
gint count)
|
||||||
{
|
{
|
||||||
guint total = count;
|
guint total = 0;
|
||||||
|
|
||||||
while (count > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
gint bytes = fread ((char *) data, sizeof (char), count, fp);
|
gint bytes = fread ((char *) data, sizeof (char), count, fp);
|
||||||
|
|
||||||
if (bytes <= 0) /* something bad happened */
|
if (bytes <= 0) /* something bad happened */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
total += bytes;
|
||||||
|
|
||||||
count -= bytes;
|
count -= bytes;
|
||||||
data += bytes;
|
data += bytes;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user