[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12265: Check that localtime_r succe
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12265: Check that localtime_r succeeds and return 0 if it doesn't. This prevents |
Date: |
Sun, 20 Jun 2010 16:01:47 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12265 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sun 2010-06-20 16:01:47 +0200
message:
Check that localtime_r succeeds and return 0 if it doesn't. This prevents
use of uninitialized data when a large value is passed.
Add tests for StaticText hits (Gnash fails).
modified:
libbase/ClockTime.cpp
testsuite/misc-ming.all/DefineTextTest-Runner.cpp
testsuite/misc-ming.all/DefineTextTest.c
=== modified file 'libbase/ClockTime.cpp'
--- a/libbase/ClockTime.cpp 2010-01-18 07:18:49 +0000
+++ b/libbase/ClockTime.cpp 2010-06-19 16:35:34 +0000
@@ -158,7 +158,12 @@
struct tm tm;
#ifdef HAVE_LOCALTIME_R
- localtime_r(&tt, &tm);
+
+ // If the requested time exceeds the limits we return 0; otherwise we'll
+ // be using uninitialized values
+ if (!localtime_r(&tt, &tm)) {
+ return 0;
+ }
#else
struct tm *tmp = NULL;
tmp = localtime(&tt);
@@ -174,7 +179,10 @@
ttmp = mktime(&tm2);
#ifdef HAVE_LOCALTIME_R
- localtime_r(&ttmp, &tm2); // find out whether DST is in force
+ // find out whether DST is in force
+ if (!localtime_r(&ttmp, &tm2)) {
+ return 0;
+ }
#else
struct tm *tmp2 = NULL;
tmp2 = localtime(&ttmp);
=== modified file 'testsuite/misc-ming.all/DefineTextTest-Runner.cpp'
--- a/testsuite/misc-ming.all/DefineTextTest-Runner.cpp 2010-01-01 17:48:26
+0000
+++ b/testsuite/misc-ming.all/DefineTextTest-Runner.cpp 2010-06-20 11:30:39
+0000
@@ -47,7 +47,7 @@
MovieClip* root = tester.getRootMovie();
assert(root);
- check_equals(root->get_frame_count(), 3);
+ check_equals(root->get_frame_count(), 4);
check_equals(root->getPlayState(), MovieClip::PLAYSTATE_PLAY);
check_equals(root->get_current_frame(), 0);
@@ -75,14 +75,49 @@
check_pixel(cOmr.x, cOmr.y, 4, green, 2); // O right side
check_pixel(cOum.x, cOum.y, 20, white, 2); // O underline (none)
- for (int i=0; i<2; ++i) tester.advance(); // get to the end
+ tester.advance();
+
+ // Move to left part of O
+ tester.movePointerTo(cOml.x, cOml.y);
+
+ // Click there
+ tester.click();
+
+ // Move to centre of O
+ tester.movePointerTo(cOmm.x, cOmm.y);
+
+ // Click there a lot (shouldn't be registered)
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+
+ // Move to right part of O
+ tester.movePointerTo(cOmr.x, cOmr.y);
+
+ // Click there.
+ tester.click();
+ tester.movePointerTo(1, 1);
+
+ // Just for fun. These shouldn't be registered.
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+ tester.click();
+
+ for (int i=0; i<3; ++i) tester.advance(); // get to the end
string_table& st = VM::get().getStringTable();
as_value eot;
bool endOfTestFound = getObject(root)->get_member(st.find("endoftest"),
&eot);
- check(endOfTestFound);
- check(eot.is_bool());
- check(eot.to_bool());
+ xcheck(endOfTestFound);
+ xcheck(eot.is_bool());
+ xcheck(eot.to_bool());
// TODO: use check_pixel for checking bacground colors
}
=== modified file 'testsuite/misc-ming.all/DefineTextTest.c'
--- a/testsuite/misc-ming.all/DefineTextTest.c 2010-01-01 17:48:26 +0000
+++ b/testsuite/misc-ming.all/DefineTextTest.c 2010-06-20 11:30:39 +0000
@@ -101,7 +101,7 @@
SWFText_addString(tf, "X", NULL);
mc = newSWFMovieClip();
- it = SWFMovieClip_add(mc, tf);
+ it = SWFMovieClip_add(mc, (SWFBlock)tf);
SWFDisplayItem_setName(it, "stext1");
SWFMovieClip_nextFrame(mc);
@@ -111,6 +111,42 @@
}
SWFMovie_nextFrame(mo); // 2nd frame
+
+ add_actions(mo,
+ "_root.note('Follow the instructions. "
+ "Click means press and release');"
+ "instructions = [ "
+ " 'Move the mouse onto the green O',"
+ " 'Click',"
+ " 'Move the mouse to the centre of the O',"
+ " 'Click as much as you like then move back onto the green O',"
+ " 'Click',"
+ " 'Move outside the green O' ];"
+ "_global.events = 0;"
+ "_global.clicks = 0;"
+ "_global.mouseInOut = 0;"
+ "checkEvents = function() {"
+ " if (_global.events == instructions.length) {"
+ " play();"
+ " }"
+ " else { _root.note(instructions[_global.events++]); };"
+ "};"
+ "mc.onPress = function() {"
+ " _global.clicks++;"
+ " checkEvents();"
+ "};"
+ "mc.onRollOver = function() {"
+ " _global.mouseInOut++;"
+ " checkEvents();"
+ "};"
+ "mc.onRollOut = function() {"
+ " _global.mouseInOut++;"
+ " checkEvents();"
+ "};"
+ "checkEvents();"
+ );
+
+
// static text is not a referenceable char
check_equals(mo, "mc.stext1", "mc");
check_equals(mo, "typeof(mc.stext1)", "'movieclip'");
@@ -118,6 +154,13 @@
check_equals(mo, "mc._width", "288.05");
+ // Wait for mouse clicks.
+ add_actions(mo, "stop();");
+
+ SWFMovie_nextFrame(mo);
+
+ xcheck_equals(mo, "_global.clicks", "2");
+ xcheck_equals(mo, "_global.mouseInOut", "4");
add_actions(mo, "endoftest=true; totals(); stop();");
SWFMovie_nextFrame(mo); // 3rd frame
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12265: Check that localtime_r succeeds and return 0 if it doesn't. This prevents,
Benjamin Wolsey <=