Selaa lähdekoodia

fixed small bugs

UwU 1 kuukausi sitten
vanhempi
commit
a6faa09975

+ 1 - 1
src/WallpaperEngine/Audio/AudioStream.cpp

@@ -95,7 +95,7 @@ int64_t audio_seek_data_callback (void* streamarg, int64_t offset, int whence) {
 	return end;
     }
 
-    switch (whence) {
+    switch (whence & ~AVSEEK_FORCE) {
 	case SEEK_CUR:
 	    stream->getBuffer ()->seekg (offset, std::ios_base::cur);
 	    break;

+ 8 - 1
src/WallpaperEngine/Render/Drivers/Output/WaylandOutputViewport.cpp

@@ -2,6 +2,7 @@
 #include "WallpaperEngine/Desktop/GnomeShell.h"
 #include "WallpaperEngine/Logging/Log.h"
 
+#include <cstdlib>
 #include <unistd.h>
 
 #define class _class
@@ -496,7 +497,13 @@ void WaylandOutputViewport::createEGLSurface () {
 	return;
     }
 
-    static const auto XCURSORSIZE = getenv ("XCURSOR_SIZE") ? std::stoi (getenv ("XCURSOR_SIZE")) : 24;
+    static const auto XCURSORSIZE = [] {
+	const char* text = getenv ("XCURSOR_SIZE");
+	char* end = nullptr;
+	const long size = text != nullptr ? std::strtol (text, &end, 10) : 0;
+
+	return text != nullptr && end != text && size > 0 && size <= 1024 ? static_cast<int> (size) : 24;
+    }();
     cursorTheme
 	= wl_cursor_theme_load (getenv ("XCURSOR_THEME"), XCURSORSIZE * scale, m_driver->getWaylandContext ()->shm);
 

+ 6 - 4
src/WallpaperEngine/Render/TextureCache.cpp

@@ -342,9 +342,10 @@ void blitTexturePatch (
 	    for (uint32_t column = 0; column < patch.width; column++) {
 		uint32_t src;
 		uint32_t dst;
-		unsigned char* out = target + 4 * (column + patch.x + targetWidth * (row + patch.y));
+		unsigned char* out
+		    = target + 4 * (column + patch.x + static_cast<size_t> (targetWidth) * (row + patch.y));
 
-		memcpy (&src, source + 4 * (column + row * patch.width), 4);
+		memcpy (&src, source + 4 * (column + static_cast<size_t> (row) * patch.width), 4);
 		memcpy (&dst, out, 4);
 
 		const uint32_t alpha = src >> 24;
@@ -478,8 +479,9 @@ void applyTexturePatches (Texture& texture, const Project& project) {
 		    break;
 		}
 
-		if (patch->width == 0 || patch->height == 0 || patch->x + patch->width > mipmap->width
-		    || patch->y + patch->height > mipmap->height || patch->data.empty ()) {
+		if (patch->width == 0 || patch->height == 0
+		    || static_cast<uint64_t> (patch->x) + patch->width > mipmap->width
+		    || static_cast<uint64_t> (patch->y) + patch->height > mipmap->height || patch->data.empty ()) {
 		    continue;
 		}
 

+ 1 - 1
src/WallpaperEngine/WebBrowser/CEF/WPSchemeHandler.cpp

@@ -142,7 +142,7 @@ bool WPSchemeHandler::Open (CefRefPtr<CefRequest> request, bool& handle_request,
 		    ? std::atoll (range.c_str () + dash + 1)
 		    : this->m_totalSize - 1;
 
-		if (start >= 0 && start < this->m_totalSize) {
+		if (start >= 0 && start < this->m_totalSize && last >= start) {
 		    this->m_partial = true;
 		    this->m_rangeStart = start;
 		    this->m_remaining = std::min (last, this->m_totalSize - 1) - start + 1;

+ 4 - 2
tools/static_analysis.py

@@ -124,8 +124,10 @@ def run_csa(build, out, jobs, full=False):
         wrapper.chmod(0o755)
         command = ['analyze-build', '--cdb', str(shard / 'compile_commands.json'),
                    '--output', str(shard / 'reports'), '--plist', '--use-analyzer', str(wrapper)]
-        for checker in CSA_FULL_CHECKERS if full else []:
-            command += ['--enable-checker', checker]
+        if full:
+            command += ['-analyzer-config', 'aggressive-binary-operation-simplification=true']
+            for checker in CSA_FULL_CHECKERS:
+                command += ['--enable-checker', checker]
         shards.append(subprocess.Popen(command))
     for process in shards:
         process.wait()