Skip to content

Commit 6f8c9ad

Browse files
committed
Clamp pinned message count
1 parent 3357e66 commit 6f8c9ad

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Telegram.Native/VideoAnimation.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,20 @@ namespace winrt::Telegram::Native::implementation
487487
return result;
488488
}
489489

490+
inline double clamp(double value, double min, double max)
491+
{
492+
if (value > max)
493+
{
494+
return max;
495+
}
496+
else if (value < min)
497+
{
498+
return min;
499+
}
500+
501+
return value;
502+
}
503+
490504
int VideoAnimation::RenderSync(uint8_t* pixels, int32_t width, int32_t height, bool preview, double& seconds, bool& completed)
491505
{
492506
slim_lock_guard const guard(m_lock);
@@ -532,7 +546,7 @@ namespace winrt::Telegram::Native::implementation
532546

533547
//if (nextFrame >= prevFrame + 1.0 / 30 || framerate < 60)
534548
{
535-
seconds = nextFrame;
549+
seconds = clamp(nextFrame, 0, duration);
536550
prevFrame = nextFrame;
537551

538552
decode_frame(pixels, width, height);

Telegram/Controls/Chats/ChatPinnedMessage.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// file LICENSE or copy at https://www.gnu.org/licenses/gpl-3.0.txt)
66
//
77
using Microsoft.Graphics.Canvas.Geometry;
8+
using System;
89
using System.Collections.Generic;
910
using System.Numerics;
1011
using Telegram.Common;
@@ -612,6 +613,8 @@ private void OnFillChanged(SolidColorBrush newValue, SolidColorBrush oldValue)
612613

613614
public void UpdateIndex(int value, int maximum, int direction)
614615
{
616+
maximum = Math.Clamp(maximum, 0, int.MaxValue);
617+
615618
if (_maskPath == null || (_nextValue == value && _nextMaximum == maximum))
616619
{
617620
return;

0 commit comments

Comments
 (0)