[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h tes...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h tes... |
Date: |
Thu, 23 Aug 2007 14:10:54 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/08/23 14:10:54
Modified files:
. : ChangeLog
libamf : amf.cpp amf.h
testsuite/libamf.all: Makefile.am test_object.cpp
test_string.cpp test_variable.cpp
Log message:
* libamf/amf.{cpp,h}: fixed a bunch of memory errors, added
some dox, first pass to interface clean ups.
* testsuite/libamf.all/Makefile.am: add testsuite/ to the
include dir, to allow for using our check_equals functions.
* testsuite/libamf.all/: test_object.cpp, test_string.cpp,
test_variable.cpp: fixed new[]/delete mismatches.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4082&r2=1.4083
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/Makefile.am?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_object.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_string.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_variable.cpp?cvsroot=gnash&r1=1.6&r2=1.7
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4082
retrieving revision 1.4083
diff -u -b -r1.4082 -r1.4083
--- ChangeLog 23 Aug 2007 14:06:54 -0000 1.4082
+++ ChangeLog 23 Aug 2007 14:10:53 -0000 1.4083
@@ -1,3 +1,12 @@
+2007-08-23 Sandro Santilli <address@hidden>
+
+ * libamf/amf.{cpp,h}: fixed a bunch of memory errors, added
+ some dox, first pass to interface clean ups.
+ * testsuite/libamf.all/Makefile.am: add testsuite/ to the
+ include dir, to allow for using our check_equals functions.
+ * testsuite/libamf.all/: test_object.cpp, test_string.cpp,
+ test_variable.cpp: fixed new[]/delete mismatches.
+
2007-08-23 Udo Giacomozzi <address@hidden>
* backend/render_handler_agg.cpp: Initial support for glyphs
Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- libamf/amf.cpp 23 Aug 2007 01:57:02 -0000 1.40
+++ libamf/amf.cpp 23 Aug 2007 14:10:54 -0000 1.41
@@ -17,7 +17,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
-/* $Id: amf.cpp,v 1.40 2007/08/23 01:57:02 nihilus Exp $ */
+/* $Id: amf.cpp,v 1.41 2007/08/23 14:10:54 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -293,14 +293,15 @@
/// normal ASCII. It may be that these need to be converted to wide
/// characters, but for now we just leave them as standard multibyte
/// characters.
-void *
+byte*
AMF::encodeElement(astype_e type, const void *in, int nbytes)
{
GNASH_REPORT_FUNCTION;
- char *out = NULL, *x;
amfnum_t num;
- int pktsize = -1;
+ int pktsize = 0;
+ byte* out = NULL;
+ byte* x = NULL;
// Packets are of varying length. A few pass in a byte count, but
// most packets have a hardcoded size.
@@ -360,12 +361,17 @@
pktsize = 0; // look for the terminator
break;
// FIXME, shouldn't there be a default case here?
+ default:
+ log_error("Unknown AMF packet type %d", type);
+ return 0;
};
+ log_debug("pktsize:%d, nbytes:%d", pktsize, nbytes);
+
switch (type) {
- // Encode the data as a 64 bit, big-endian, numeric value
case NUMBER:
- x = out = new char[pktsize];
+ // Encode the data as a 64 bit, big-endian, numeric value
+ x = out = new byte[pktsize];
memset(x, 0, pktsize);
*x++ = (char)AMF::NUMBER;
memcpy(&num, in, AMF_NUMBER_SIZE);
@@ -374,7 +380,7 @@
break;
case BOOLEAN:
// Encode a boolean value. 0 for false, 1 for true
- out = new char[pktsize];
+ out = new byte[pktsize];
x = out;
*x++ = (char)AMF::BOOLEAN;
*x = *static_cast<const char *>(in);
@@ -382,11 +388,13 @@
case STRING:
// Encode a string value. The data follows a 2 byte length
// field. (which must be big-endian)
- x = out = new char[pktsize];
+ x = out = new byte[pktsize];
memset(x, 0, pktsize);
*x++ = AMF::STRING;
num = nbytes;
+ log_debug("Encoded data size is going to be " AMFNUM_F, num);
swapBytes(&num, 2);
+ log_debug("After swapping, it's " AMFNUM_F, num);
memcpy(x, &num, 2);
x+=2;
memcpy(x, in, nbytes);
@@ -401,7 +409,7 @@
log_unimpl("Null AMF encoder");
break;
case UNDEFINED:
- x = out = new char[pktsize];
+ x = out = new byte[pktsize];
memset(x, 0, pktsize);
*x++ = AMF::UNDEFINED;
num = nbytes;
@@ -424,7 +432,7 @@
break;
// Encode the date as a 64 bit, big-endian, numeric value
case DATE:
- x = out = new char[pktsize];
+ x = out = new byte[pktsize];
memset(x, 0, pktsize);
*x++ = AMF::DATE;
num = *static_cast<const amfnum_t*>(in);
@@ -443,7 +451,7 @@
case XML_OBJECT:
// Encode an XML object. The data follows a 4 byte length
// field. (which must be big-endian)
- x = out = new char[pktsize];
+ x = out = new byte[pktsize];
memset(x, 0, pktsize);
*x++ = AMF::STRING;
num = nbytes;
@@ -712,20 +720,21 @@
}
char *
-AMF::extractString(const char *in)
+AMF::extractString(const byte *in)
{
GNASH_REPORT_FUNCTION;
char *buf = NULL;
- char *x = const_cast<char*>(in);
- short length;
+ const byte *x = in;
if (*x == AMF::STRING) {
x++;
- length = *(reinterpret_cast<short *>(x));
+ short length = *(reinterpret_cast<const short *>(x));
+ swapBytes(&length, 2);
+ log_debug("Encoded length of string: %hd", length);
x += sizeof(short);
buf = new char[length+1];
memset(buf, 0, length+1);
- strncpy(buf, x, length); /* memcpy() does memory access violation on
Darwin! */
+ memcpy(buf, x, length); /* x is not long enough */
} else {
log_error("Tried to extract AMF string from non String object!");
}
@@ -739,7 +748,7 @@
GNASH_REPORT_FUNCTION;
char *x = const_cast<char *>(in);
amfnum_t *num = new amfnum_t;
- memset(num, 0, AMF_NUMBER_SIZE+1);
+ memset(num, 0, AMF_NUMBER_SIZE);
if (*x == AMF::NUMBER) {
x++;
@@ -752,29 +761,29 @@
return num;
}
-void *
+byte *
AMF::encodeVariable(amf_element_t & /* el */)
{
GNASH_REPORT_FUNCTION;
return NULL;
}
-void *
+byte *
AMF::encodeVariable(const char *name, bool flag)
{
GNASH_REPORT_FUNCTION;
int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
- char *out = new char[outsize];
- char *tmpptr = out;
- short length;
+ byte *out = new byte[outsize];
+ byte *tmpptr = out;
- length = strlen(name);
- swapBytes(&length, 2);
- memcpy(tmpptr, &length, 2);
+ size_t length = strlen(name);
+ short enclength = length;
+ swapBytes(&enclength, 2);
+ memcpy(tmpptr, &enclength, 2);
tmpptr += 2;
- strcpy(tmpptr, name);
- tmpptr += strlen(name);
+ memcpy(tmpptr, name, length);
+ tmpptr += length;
*tmpptr = AMF::BOOLEAN;
tmpptr++;
*tmpptr = flag;
@@ -782,44 +791,44 @@
return out;
}
-void *
+byte *
AMF::encodeVariable(const char *name)
{
GNASH_REPORT_FUNCTION;
- int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
- char *out = new char[outsize];
- char *tmpptr = out;
- short length;
-
- length = strlen(name);
- swapBytes(&length, 2);
- memcpy(tmpptr, &length, 2);
+ size_t outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
+ byte *out = new byte[outsize];
+ byte *tmpptr = out;
+
+ size_t length = strlen(name);
+ short enclength = length;
+ swapBytes(&enclength, 2);
+ memcpy(tmpptr, &enclength, 2);
tmpptr += 2;
- strcpy(tmpptr, name);
- tmpptr += strlen(name);
+ memcpy(tmpptr, name, length);
+ tmpptr += length;
*tmpptr = AMF::UNDEFINED;
tmpptr++;
return out;
}
-void *
+byte *
AMF::encodeVariable(const char *name, amfnum_t bignum)
{
GNASH_REPORT_FUNCTION;
int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
- char *out = new char[outsize];
- char *tmpptr = out;
- short length;
+ byte *out = new byte[outsize];
+ byte *tmpptr = out;
amfnum_t newnum = bignum;
char *numptr = (char *)&newnum;
- length = strlen(name);
- swapBytes(&length, 2);
- memcpy(tmpptr, &length, 2);
+ size_t length = strlen(name);
+ short enclength = length;
+ swapBytes(&enclength, 2);
+ memcpy(tmpptr, &enclength, 2);
tmpptr += 2;
- strcpy(tmpptr, name);
- tmpptr += strlen(name);
+ memcpy(tmpptr, name, length);
+ tmpptr += length;
*tmpptr = AMF::NUMBER;
tmpptr++;
// swapBytes(numptr, AMF_NUMBER_SIZE);
@@ -828,41 +837,42 @@
return out;
}
-void *
+byte *
AMF::encodeVariable(const char *name, const char *val)
{
GNASH_REPORT_FUNCTION;
int outsize = strlen(name) + strlen(val) + 5;
- char *out = new char[outsize];
- char *tmpptr = out;
- short length;
+ byte *out = new byte[outsize];
+ byte *tmpptr = out;
- length = strlen(name);
- swapBytes(&length, 2);
- memcpy(tmpptr, &length, 2);
+ size_t length = strlen(name);
+ short enclength = length;
+ swapBytes(&enclength, 2);
+ memcpy(tmpptr, &enclength, 2);
tmpptr += 2;
- strcpy(tmpptr, name);
- tmpptr += strlen(name);
+ memcpy(tmpptr, name, length);
+ tmpptr += length;
*tmpptr = AMF::STRING;
tmpptr++;
length = strlen(val);
- swapBytes(&length, 2);
- memcpy(tmpptr, &length, 2);
+ enclength = length;
+ swapBytes(&enclength, 2);
+ memcpy(tmpptr, &enclength, 2);
tmpptr += 2;
- strcpy(tmpptr, val);
+ memcpy(tmpptr, val, length);
return out;
}
-void *
+byte *
AMF::encodeVariable(std::string &name, std::string &val)
{
GNASH_REPORT_FUNCTION;
int outsize = name.size() + val.size() + 5;
- unsigned char *out = new unsigned char[outsize];
- unsigned char *tmpptr = out;
+ byte *out = new unsigned char[outsize];
+ byte *tmpptr = out;
short length;
length = name.size() && 0xffff;
@@ -1188,27 +1198,30 @@
break;
}
case STRING:
+ {
length = ntohs((*(const short *)tmpptr) & 0xffff);
tmpptr += sizeof(short);
el->data = (const unsigned char*)tmpptr;
- log_msg(_("Variable \"%s\" is: %s"), el->name.c_str(), el->data);
+ std::string v((char*)el->data, length);
+ log_msg(_("Variable \"%s\" is: %s"), el->name.c_str(), v.c_str());
// el->data);
tmpptr += length;
el->length = length;
break;
+ }
case OBJECT:
case MOVIECLIP:
case NULL_VALUE:
// Undefined types have a name, but no value
//FIXME this shouldn't fall through!
case UNDEFINED:
+ {
log_msg(_("Undefined type"));
- length = ntohs((*(const short *)tmpptr) & 0xffff);
- el->data = (const unsigned char*)tmpptr;
- log_msg(_("Variable \"%s\" is: %s"), el->name.c_str(), el->data);
-// tmpptr += length;
- el->length = length;
+ el->data = 0; // (const unsigned char*)tmpptr;
+ //log_msg(_("Variable \"%s\" is of undefined type"),
el->name.c_str());
+ el->length = 0;
el->type = AMF::UNDEFINED;
break;
+ }
case REFERENCE:
case ECMA_ARRAY:
// FIXME this shouldn't fall thru
Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- libamf/amf.h 1 Jul 2007 10:54:05 -0000 1.21
+++ libamf/amf.h 23 Aug 2007 14:10:54 -0000 1.22
@@ -39,6 +39,8 @@
typedef long long amfnum_t;
#define AMFNUM_F "%lld"
#endif
+// TIDO FIXME: this will be longer then the actual amfnum_t
+// if __WORDSIZE != 64 !!
const char AMF_NUMBER_SIZE = 0x08;
// These are the data types defined by AMF
@@ -48,6 +50,8 @@
typedef int AMF_Long_t;
typedef double AMF_Double_t;
+typedef unsigned char byte;
+
// FIXME: These are probably bogus, and need to be a UTF-8 type.
typedef char *AMF_UTF8_t;
typedef char *AMF_LongUTF8_t;
@@ -74,15 +78,15 @@
//
// The first byte of the AMF file/stream is believed to be a version
// indicator. So far the only valid value for this field that has been
-// found is 0×00. If it is anything other than 0×00 (zero), your
+// found is 0x00. If it is anything other than 0x00 (zero), your
// system should consider the AMF file/stream to be
// 'cmalformed'd. This can happen in the IDE if AMF calls are put
// on the stack but never executed and the user exits the movie from the
// IDE; the two top bytes will be random and the number of headers will
// be unreliable.
-// The second byte of the AMF file/stream is appears to be 0×00 if the
-// client is the Flash Player and 0×01 if the client is the FlashCom
+// The second byte of the AMF file/stream is appears to be 0x00 if the
+// client is the Flash Player and 0x01 if the client is the FlashCom
// server.
// The third and fourth bytes form an integer value that specifies the
@@ -166,39 +170,100 @@
DELETE_ATTRIBYTE = 0x0a,
INITIAL_DATA = 0x0b
} shared_obj_types_e;
- typedef struct {
+
+ struct amf_element_t {
astype_e type;
short length;
std::string name;
const unsigned char *data;
- } amf_element_t;
+
+ amf_element_t()
+ :
+ type(NUMBER),
+ length(0),
+ name(),
+ data(NULL)
+ {}
+
+ };
AMF();
AMF(int size);
~AMF();
size_t size() { return _total_size; };
- // encode an element
- void *encodeElement(astype_e type, const void *in, int nbytes);
- // encode a string
- void *encodeString(char *str) {
+ /// Encode an element
+ //
+ /// @param type
+ /// Type of element
+ ///
+ /// @param in
+ /// Input stream
+ ///
+ /// @param nbytes
+ /// Lenght of data packet (not including header).
+ ///
+ /// @return an amf packet (header,data)
+ ///
+ byte* encodeElement(astype_e type, const void *in, int nbytes);
+
+ /// Encode a string
+ ///
+ /// @return an amf packet (header,data)
+ ///
+ byte* encodeString(const char *str) {
return encodeElement (STRING, str, strlen(str));
};
- void *encodeString(std::string &str) {
- return encodeElement (STRING, static_cast<const void *>(str.c_str()),
str.size());
- };
- // encode a 64 bit number
- void *encodeNumber(amfnum_t num) {
+
+ /// Encode a 64 bit number
+ ///
+ /// @return an amf packet (header,data)
+ ///
+ byte* encodeNumber(amfnum_t num) {
return encodeElement (NUMBER, &num, AMF_NUMBER_SIZE);
};
- // encode a variable. These are a name, followed by a string or number
- void *encodeVariable(const char *name);
- void *encodeVariable(amf_element_t &el);
- void *encodeVariable(const char *name, bool flag);
- void *encodeVariable(const char *name, amfnum_t num);
- void *encodeVariable(std::string &name, std::string &val);
- void *encodeVariable(const char *name, const char *val);
+ /// Encode a variable. These are a name, followed by a string or number
+ //
+ /// @return a newly allocated byte array,
+ /// to be deleted by caller using delete [] operator, or NULL
+ ///
+ byte* encodeVariable(const char *name);
+
+ /// Encode a variable.
+ //
+ /// @return a newly allocated byte array,
+ /// to be deleted by caller using delete [] operator, or NULL
+ ///
+ byte* encodeVariable(amf_element_t &el);
+
+ /// Encode a boolean variable. This is a name followed by a boolean value.
+ //
+ /// @return a newly allocated byte array,
+ /// to be deleted by caller using delete [] operator, or NULL
+ ///
+ byte* encodeVariable(const char *name, bool flag);
+
+ /// Encode a variable.
+ //
+ /// @return a newly allocated byte array,
+ /// to be deleted by caller using delete [] operator, or NULL
+ ///
+ byte* encodeVariable(const char *name, amfnum_t num);
+
+ /// Encode a variable.
+ //
+ /// @return a newly allocated byte array,
+ /// to be deleted by caller using delete [] operator, or NULL
+ ///
+ byte* encodeVariable(std::string &name, std::string &val);
+
+ /// Encode a variable.
+ //
+ /// @return a newly allocated byte array,
+ /// to be deleted by caller using delete [] operator, or NULL
+ ///
+ byte* encodeVariable(const char *name, const char *val);
void *encodeRTMPHeader(int amf_index, amf_headersize_e head_size, int
total_size,
content_types_e type, amfsource_e routing);
@@ -208,9 +273,15 @@
char *readElement(void *in);
- astype_e extractElementHeader(void *in);
- int extractElementLength(void *in);
- char *extractString(const char *in);
+ /// Extract the string from a string-type AMF packet
+ //
+ /// Return a newly allocated char[],
+ /// or NULL if the given AMF packet is not a string type
+ ///
+ /// Caller is responsible for deletion using delete [] operator.
+ ///
+ char *extractString(const byte* in);
+
amfnum_t *extractNumber(const char *in);
amf_element_t *extractObject(const char *in);
@@ -242,6 +313,11 @@
}
private:
+
+ astype_e extractElementHeader(void *in);
+
+ int extractElementLength(void *in);
+
content_types_e _type;
std::map<std::string, amf_element_t *> _elements;
int _amf_index;
Index: testsuite/libamf.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/Makefile.am,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- testsuite/libamf.all/Makefile.am 19 Aug 2007 20:07:42 -0000 1.5
+++ testsuite/libamf.all/Makefile.am 23 Aug 2007 14:10:54 -0000 1.6
@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# $Id: Makefile.am,v 1.5 2007/08/19 20:07:42 nihilus Exp $
+# $Id: Makefile.am,v 1.6 2007/08/23 14:10:54 strk Exp $
AUTOMAKE_OPTIONS = dejagnu
@@ -37,6 +37,7 @@
-I$(top_srcdir)/libamf \
-I$(top_srcdir)/libbase \
-I$(top_srcdir)/server \
+ -I$(top_srcdir)/testsuite \
$(LIBXML_CFLAGS) \
$(DMALLOC_CFLAGS) \
$(CURL_CFLAGS) \
Index: testsuite/libamf.all/test_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_object.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/libamf.all/test_object.cpp 1 Jul 2007 10:54:44 -0000
1.7
+++ testsuite/libamf.all/test_object.cpp 23 Aug 2007 14:10:54 -0000
1.8
@@ -31,9 +31,10 @@
#include <iostream>
#include <string>
-#include "dejagnu.h"
+//#include "dejagnu.h"
#include "rtmp.h"
#include "amf.h"
+#include "check.h"
using namespace amf;
using namespace gnash;
@@ -72,6 +73,9 @@
char buffer[300];
int c;
+ //gnash::LogFile& dbglogfile = gnash::LogFile::getDefaultInstance();
+ //dbglogfile.setVerbosity(1);
+
memset(buffer, 0, 300);
while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
@@ -142,7 +146,7 @@
// This extracts a "connect" message from the RTMP data stream. We
// look for everything ourselves to be the most accurate.
tmpptr = buf + amf_obj.getHeaderSize();
- char *str = amf_obj.extractString((char *)tmpptr);
+ char *str = amf_obj.extractString(tmpptr);
if (strcmp(str, "connect") == 0) {
runtest.pass("Extracted \"connect\" string");
} else {
@@ -278,10 +282,20 @@
runtest.fail("New Message Routing");
}
+ check_equals(rtmp.getHeaderSize(), 12);
+
if (memcmp(out, buf, 12) == 0) {
runtest.pass("RTMP Headers match");
} else {
- runtest.fail("RTMP Headers match");
+ size_t s = 12;
+ runtest.fail("RTMP Headers mismatch");
+ unsigned char hexint[(s*2)+1];
+ hexify((unsigned char *)hexint, (unsigned char *)buf, s, true);
+ hexint[s*2] = '\0';
+ cerr << "buf is: 0x" << hexint << endl;
+ hexify((unsigned char *)hexint, (unsigned char *)out, s, true);
+ hexint[s*2] = '\0';
+ cerr << "out is: 0x" << hexint << endl;
}
tmpptr += rtmp.getHeaderSize();
@@ -290,13 +304,25 @@
unsigned char *var;
var = (unsigned char *)rtmp.encodeString("connect");
- if (strncmp(rtmp.extractString((char *)var), "connect", strlen("connect"))
== 0) {
+ char* c_out = rtmp.extractString(var);
+ if ( ! c_out )
+ {
+ runtest.fail("Encoded \"connect\" string could not be extracted");
+ }
+ else
+ {
+ std::string s_in("connect");
+ std::string s_out(c_out);
+
+ if (s_in == s_out) {
runtest.pass("Encoded \"connect\" string");
} else {
runtest.fail("Encoded \"connect\" string");
+ cerr << "Encoded 'connect' returned as as" << s_out << endl;
+ }
}
tmpptr = rtmp.appendPtr(tmpptr, var, strlen("connect") + 3);
- delete var;
+ delete [] var;
amfnum_t bignum = 0x3ff0000000000000LL;
numptr = (char *)&bignum;
@@ -308,7 +334,7 @@
}
tmpptr = rtmp.appendPtr(tmpptr, var, AMF_NUMBER_SIZE + 1);
- delete var;
+ delete [] var;
// Start the object
*tmpptr++ = AMF::OBJECT;
@@ -321,7 +347,7 @@
runtest.fail("Encoded \"app\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.length + strlen("app") + 5);
- delete var;
+ delete [] var;
var = (unsigned char *)rtmp.encodeVariable("flashVer", "LNX 9,0,31,0");
rtmp.extractVariable(&el, var);
@@ -331,7 +357,7 @@
runtest.fail("Encoded \"flashVer\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.length + strlen("flashVer") + 5);
- delete var;
+ delete [] var;
var = (unsigned char *)rtmp.encodeVariable("swfUrl",
"http://www.red5.nl/tools/publisher/publisher.swf");
rtmp.extractVariable(&el, var);
@@ -341,7 +367,7 @@
runtest.fail("Encoded \"swfUrl\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.length + strlen("swfUrl") + 5);
- delete var;
+ delete [] var;
var = (unsigned char *)rtmp.encodeVariable("tcUrl",
"rtmp://localhost/oflaDemo");
rtmp.extractVariable(&el, var);
@@ -351,7 +377,7 @@
runtest.fail("Encoded \"tcUrl\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.length + strlen("tcUrl") + 5);
- delete var;
+ delete [] var;
var = (unsigned char *)rtmp.encodeVariable("fpad", false);
rtmp.extractVariable(&el, var);
@@ -361,7 +387,7 @@
runtest.fail("Encoded \"fpad\" Boolean variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, 1 + strlen("fpad") + 3);
- delete var;
+ delete [] var;
bignum = 0x388340LL;
numptr = (char *)&bignum;
@@ -378,7 +404,7 @@
runtest.fail("Encoded \"audioCodecs\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.name.size() + AMF_NUMBER_SIZE + 3);
- delete var;
+ delete [] var;
bignum = 0x5f40LL;
numptr = (char *)&bignum;
@@ -394,7 +420,7 @@
runtest.fail("Encoded \"videoCodecs\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.name.size() + AMF_NUMBER_SIZE + 3);
- delete var;
+ delete [] var;
bignum = 0xf03fLL;
numptr = (char *)&bignum;
@@ -410,7 +436,7 @@
runtest.fail("Encoded \"videoFunction\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.name.size() + AMF_NUMBER_SIZE + 3);
- delete var;
+ delete [] var;
var = (unsigned char *)rtmp.encodeVariable("pageUrl");
rtmp.extractVariable(&el, var);
@@ -421,7 +447,7 @@
runtest.fail("Encoded \"pageUrl\" undefined variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.name.size() + 3);
- delete var;
+ delete [] var;
bignum = 0x0;
numptr = (char *)&bignum;
@@ -437,7 +463,7 @@
runtest.fail("Encoded \"objectEncoding\" variable");
}
tmpptr = rtmp.appendPtr(tmpptr, var, el.name.size() + AMF_NUMBER_SIZE + 3);
- delete var;
+ delete [] var;
// Start the object
*tmpptr++ = AMF::OBJECT_END;
@@ -445,13 +471,16 @@
if (memcmp(buf, out, amf_obj.getTotalSize()) == 0) {
runtest.pass("Object Packets match");
} else {
- runtest.fail("Object Packets match");
+ runtest.fail("Object Packets mismatch");
}
- unsigned char hexint[AMF_PACKET_SIZE];
+ size_t hexsize = std::max(AMF_PACKET_SIZE, amf_obj.getTotalSize())*2;
+ unsigned char hexint[hexsize+1];
hexify((unsigned char *)hexint, (unsigned char *)buf,
amf_obj.getTotalSize() + 10, true);
+ hexint[hexsize] = '\0';
cerr << "buf is: 0x" << hexint << ", size is: " << amf_obj.getTotalSize()
<< endl;
hexify((unsigned char *)hexint, (unsigned char *)out, rtmp.getTotalSize()
+ 10, true);
+ hexint[hexsize] = '\0';
cerr << "out is: 0x" << hexint << ", size is: " << rtmp.getTotalSize() <<
endl;
// delete out;
Index: testsuite/libamf.all/test_string.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_string.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- testsuite/libamf.all/test_string.cpp 1 Jul 2007 10:54:44 -0000
1.8
+++ testsuite/libamf.all/test_string.cpp 23 Aug 2007 14:10:54 -0000
1.9
@@ -71,7 +71,7 @@
AMF amf_obj;
int fd, ret;
- char buf[AMF_VIDEO_PACKET_SIZE+1];
+ byte buf[AMF_VIDEO_PACKET_SIZE+1];
// First see if we can read strings. This file is produced by
// using a network packet sniffer, and should be binary correct.
@@ -99,7 +99,7 @@
runtest.fail("Encoded \"connect\" string");
}
- delete str;
+ delete [] str;
}
static void
Index: testsuite/libamf.all/test_variable.cpp
===================================================================
RCS file: /sources/gnash/gnash/testsuite/libamf.all/test_variable.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- testsuite/libamf.all/test_variable.cpp 1 Jul 2007 10:54:44 -0000
1.6
+++ testsuite/libamf.all/test_variable.cpp 23 Aug 2007 14:10:54 -0000
1.7
@@ -127,7 +127,7 @@
runtest.fail("Got String element data");
}
- char *out = (char *)amf_obj.encodeVariable("tcUrl",
"rtmp://localhost/oflaDemo");
+ char *out = (char*)amf_obj.encodeVariable("tcUrl",
"rtmp://localhost/oflaDemo");
if ((out[1] == 0x5)
&& (out[2] == 't')
&& (out[3] == 'c')
@@ -158,7 +158,7 @@
runtest.fail("String Packets match");
}
- delete out;
+ delete [] out;
// Test number fields
memset(buf, 0, AMF_PACKET_SIZE+1);
@@ -185,7 +185,7 @@
}
amfnum_t bignum = 0x388340L;
- out = (char *)amf_obj.encodeVariable("audioCodecs", bignum);
+ out = (char*)amf_obj.encodeVariable("audioCodecs", bignum);
if ((out[1] == 11)
&& (out[2] == 'a')
&& (out[3] == 'u')
@@ -212,7 +212,7 @@
runtest.fail("Number Packets match");
}
- delete out;
+ delete [] out;
}
static void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h tes...,
Sandro Santilli <=