Commit 0e01ba99 authored by conrad's avatar conrad
Browse files

Revert ac2015db, 46faa6b4

This reverts the following commits:

"Mozilla 520500: test for (len > 0)"
46faa6b4

Revert "Mozilla 520500, Mozilla 521863"
ac2015db

Due to a regression introduced by ac2015db, which fails to pass
"make check", and chops the first character off all comment values.
parent 896fe360
......@@ -424,33 +424,33 @@ int
fish_sound_comments_decode (FishSound * fsound, unsigned char * comments,
long length)
{
char *c= (char *)comments;
int i, nb_fields, n;
size_t len;
char *end;
char * name, * value, * nvalue = NULL;
FishSoundComment * comment;
if (length<8)
return -1;
char *c= (char *)comments;
int i, nb_fields, n;
size_t len;
char *end;
char * name, * value, * nvalue = NULL;
FishSoundComment * comment;
if (length<8)
return -1;
end = c+length;
len=readint(c, 0);
end = c+length;
len=readint(c, 0);
c+=4;
if (len > (unsigned long) length - 4) return -1;
/* Vendor */
if (len > 0) {
if ((nvalue = fs_strdup_len (c, len)) == NULL)
return FISH_SOUND_ERR_OUT_OF_MEMORY;
if (fish_sound_comment_set_vendor (fsound, nvalue) == FISH_SOUND_ERR_OUT_OF_MEMORY) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
c+=4;
if (len > (unsigned long) length - 4) return -1;
/* Vendor */
if (len > 0) {
if ((nvalue = fs_strdup_len (c, len)) == NULL)
return FISH_SOUND_ERR_OUT_OF_MEMORY;
if (fish_sound_comment_set_vendor (fsound, nvalue) == FISH_SOUND_ERR_OUT_OF_MEMORY) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
fs_free (nvalue);
}
fs_free (nvalue);
}
#ifdef DEBUG
fwrite(c, 1, len, stderr); fputc ('\n', stderr);
#endif
......@@ -474,17 +474,11 @@ fish_sound_comments_decode (FishSound * fsound, unsigned char * comments,
c+=4;
if (len > (unsigned long) (end-c)) return -1;
name = c;
value = fs_index_len (c, '=', len);
if (value) {
*value = '\0';
value++;
nvalue = 0;
n = c+len - value;
}
if (n) {
*value = '\0';
value++;
name = c;
value = fs_index_len (c, '=', len);
if (value) {
*value = '\0';
value++;
n = c+len - value;
if ((nvalue = fs_strdup_len (value, n)) == NULL)
......@@ -492,42 +486,42 @@ fish_sound_comments_decode (FishSound * fsound, unsigned char * comments,
debug_printf (1, "%s -> %s (length %d)", name, nvalue, n);
if ((comment = fs_comment_new (name, nvalue)) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
if ((comment = fs_comment_new (name, nvalue)) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
if (_fs_comment_add (fsound, comment) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
if (_fs_comment_add (fsound, comment) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
fs_free (nvalue);
} else if (len > 0) {
debug_printf (1, "[%d] %s (no value)", i, name, len);
fs_free (nvalue);
} else {
debug_printf (1, "[%d] %s (no value)", i, name, len);
if ((nvalue = fs_strdup_len (name, len)) == NULL)
return FISH_SOUND_ERR_OUT_OF_MEMORY;
if ((nvalue = fs_strdup_len (name, len)) == NULL)
return FISH_SOUND_ERR_OUT_OF_MEMORY;
if ((comment = fs_comment_new (nvalue, "")) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
if ((comment = fs_comment_new (nvalue, NULL)) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
if (_fs_comment_add (fsound, comment) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
if (_fs_comment_add (fsound, comment) == NULL) {
fs_free (nvalue);
return FISH_SOUND_ERR_OUT_OF_MEMORY;
}
fs_free (nvalue);
}
fs_free (nvalue);
}
c+=len;
}
c+=len;
}
debug_printf (1, "OUT");
debug_printf (1, "OUT");
return FISH_SOUND_OK;
return FISH_SOUND_OK;
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment