The following issues were found
java/com/google/scrollview/ScrollView.java
155 issues
Line: 62
/** Add a new message to the outgoing queue */
public static void addMessage(SVEvent e) {
if (debugViewNetworkTraffic) {
System.out.println("(S->c) " + e.toString());
}
String str = e.toString();
// Send the whole thing as UTF8.
try {
byte [] utf8 = str.getBytes("UTF8");
Reported by PMD.
Line: 70
byte [] utf8 = str.getBytes("UTF8");
out.write(utf8, 0, utf8.length);
} catch (java.io.UnsupportedEncodingException ex) {
System.out.println("Oops... can't encode to UTF8... Exiting");
System.exit(0);
}
out.println();
// Flush the output and check for errors.
boolean error = out.checkError();
Reported by PMD.
Line: 77
// Flush the output and check for errors.
boolean error = out.checkError();
if (error) {
System.out.println("Connection error. Quitting ScrollView Server...");
System.exit(0);
}
}
/** Read one message from client (assuming there are any). */
Reported by PMD.
Line: 105
}
nrInputLines++;
if (debugViewNetworkTraffic) {
System.out.println("(c->S," + nrInputLines + ")" + inputLine);
}
if (polylineSize > polylineScanned) {
// We are processing a polyline.
// Read pairs of coordinates separated by commas.
Reported by PMD.
Line: 130
}
// Some connection error
catch (IOException e) {
System.out.println("Connection error. Quitting ScrollView Server...");
}
System.exit(0);
}
// Parse a comma-separated list of arguments into ArrayLists of the
Reported by PMD.
Line: 380
// Open a socket to listen on.
try (ServerSocket serverSocket = new ServerSocket(SERVER_PORT)) {
System.out.println("Socket started on port " + SERVER_PORT);
// Wait (blocking) for an incoming connection
socket = serverSocket.accept();
System.out.println("Client connected");
Reported by PMD.
Line: 384
// Wait (blocking) for an incoming connection
socket = serverSocket.accept();
System.out.println("Client connected");
// Setup the streams
out = new PrintStream(socket.getOutputStream(), true, "UTF-8");
in =
new BufferedReader(new InputStreamReader(socket.getInputStream(),
Reported by PMD.
Line: 32
* line. It sets up LUA and handles the network processing.
* @author wanke@google.com
*/
public class ScrollView {
/** The port our server listens at. */
public static int SERVER_PORT = 8461;
/**
Reported by PMD.
Line: 32
* line. It sets up LUA and handles the network processing.
* @author wanke@google.com
*/
public class ScrollView {
/** The port our server listens at. */
public static int SERVER_PORT = 8461;
/**
Reported by PMD.
Line: 32
* line. It sets up LUA and handles the network processing.
* @author wanke@google.com
*/
public class ScrollView {
/** The port our server listens at. */
public static int SERVER_PORT = 8461;
/**
Reported by PMD.
java/com/google/scrollview/ui/SVWindow.java
85 issues
Line: 202
* @param canvasSizeX The canvas width of the window.
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
Reported by PMD.
Line: 202
* @param canvasSizeX The canvas width of the window.
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
Reported by PMD.
Line: 203
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
Reported by PMD.
Line: 203
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
Reported by PMD.
Line: 203
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
Reported by PMD.
Line: 203
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
Reported by PMD.
Line: 203
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
Reported by PMD.
Line: 203
* @param canvasSizeY The canvas height of the window.
*/
public SVWindow(String name, int hash, int posX, int posY, int sizeX,
int sizeY, int canvasSizeX, int canvasSizeY) {
super(name);
// Provide defaults for sizes.
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
Reported by PMD.
Line: 369
* stroke, pen color for the border and the brush to fill the
* interior.
*/
public void drawRectangle(int x1, int y1, int x2, int y2) {
if (x1 > x2) {
int t = x1;
x1 = x2;
x2 = t;
Reported by PMD.
Line: 369
* stroke, pen color for the border and the brush to fill the
* interior.
*/
public void drawRectangle(int x1, int y1, int x2, int y2) {
if (x1 > x2) {
int t = x1;
x1 = x2;
x2 = t;
Reported by PMD.
src/opencl/openclwrapper.cpp
68 issues
Line: 162
CWE codes:
762
ds_profile *profile = new ds_profile;
memset(profile, 0, sizeof(ds_profile));
clGetPlatformIDs(0, nullptr, &numPlatforms);
if (numPlatforms > 0) {
platforms.reserve(numPlatforms);
Reported by Cppcheck.
Line: 726
Column: 3
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
inline int OpenclDevice::AddKernelConfig(int kCount, const char *kName) {
ASSERT_HOST(kCount > 0);
ASSERT_HOST(strlen(kName) < sizeof(gpuEnv.mArrykernelNames[kCount - 1]));
strcpy(gpuEnv.mArrykernelNames[kCount - 1], kName);
gpuEnv.mnKernelCount++;
return 0;
}
int OpenclDevice::RegistOpenclKernel() {
Reported by FlawFinder.
Line: 813
Column: 3
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
const char *str = strstr(clFileName, ".cl");
memcpy(cl_name, clFileName, str - clFileName);
cl_name[str - clFileName] = '\0';
sprintf(fileName, "%s-%s.bin", cl_name, deviceName);
legalizeFileName(fileName);
fd = fopen(fileName, "rb");
status = (fd != nullptr) ? 1 : 0;
if (fd != nullptr) {
*fhandle = fd;
Reported by FlawFinder.
Line: 898
Column: 7
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
const char *str = strstr(clFileName, ".cl");
memcpy(cl_name, clFileName, str - clFileName);
cl_name[str - clFileName] = '\0';
sprintf(fileName, "%s-%s.bin", cl_name, deviceName);
legalizeFileName(fileName);
if (!WriteBinaryToFile(fileName, binaries[i], binarySizes[i])) {
tprintf("[OD] write binary[%s] failed\n", fileName);
return 0;
} // else
Reported by FlawFinder.
Line: 1027
Column: 3
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
return 0;
}
strcpy(gpuInfo->mArryKnelSrcFile[idx], filename);
if (binaryExisted == 0) {
GeneratBinFromKernelSource(gpuInfo->mpArryPrograms[idx], filename);
}
gpuInfo->mnFileCount += 1;
Reported by FlawFinder.
Line: 606
Column: 15
CWE codes:
829
20
Suggestion:
Use LoadLibraryEx with one of the search flags, or call SetSearchPathMode to use a safe search path, or pass a full path to the library
void *OpenclDll = nullptr;
// fprintf(stderr, " LoadOpenclDllxx... \n");
OpenclDll = static_cast<HINSTANCE>(HOpenclDll);
OpenclDll = LoadLibrary("openCL.dll");
if (!static_cast<HINSTANCE>(OpenclDll)) {
fprintf(stderr, "[OD] Load opencl.dll failed!\n");
FreeLibrary(static_cast<HINSTANCE>(OpenclDll));
return 0;
}
Reported by FlawFinder.
Line: 1790
Column: 3
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
};
static void populateTessScoreEvaluationInputData(TessScoreEvaluationInputData *input) {
srand(1);
// 8.5x11 inches @ 300dpi rounded to clean multiples
int height = 3328; // %256
int width = 2560; // %512
int numChannels = 4;
input->height = height;
Reported by FlawFinder.
Line: 1908
CWE codes:
476
clock_gettime(CLOCK_MONOTONIC, &time_funct_start);
# endif
OpenclDevice::gpuEnv = *env;
int wpl = pixGetWpl(input.pix);
OpenclDevice::pixReadFromTiffKernel(tiffdata, input.width, input.height, wpl, nullptr);
# if ON_WINDOWS
QueryPerformanceCounter(&time_funct_end);
time = (time_funct_end.QuadPart - time_funct_start.QuadPart) / (double)(freq.QuadPart);
Reported by Cppcheck.
Line: 1992
CWE codes:
476
clock_gettime(CLOCK_MONOTONIC, &time_funct_start);
# endif
OpenclDevice::gpuEnv = *env;
int retVal = OpenclDevice::HistogramRectOCL(input.imageData, input.numChannels, bytes_per_line,
left, top, input.width, input.height,
kHistogramSize, histogramAllChannels);
# if ON_WINDOWS
Reported by Cppcheck.
Line: 2110
CWE codes:
476
clock_gettime(CLOCK_MONOTONIC, &time_funct_start);
# endif
OpenclDevice::gpuEnv = *env;
int hi_values[4];
int retVal = OpenclDevice::ThresholdRectToPixOCL(
input.imageData, input.numChannels, bytes_per_line, thresholds, hi_values, &input.pix,
input.height, input.width, top, left);
Reported by Cppcheck.
java/com/google/scrollview/events/SVEventHandler.java
62 issues
Line: 14
package com.google.scrollview.events;
import com.google.scrollview.ScrollView;
import com.google.scrollview.events.SVEvent;
import com.google.scrollview.events.SVEventType;
import com.google.scrollview.ui.SVWindow;
import org.piccolo2d.PCamera;
import org.piccolo2d.PNode;
Reported by PMD.
Line: 15
import com.google.scrollview.ScrollView;
import com.google.scrollview.events.SVEvent;
import com.google.scrollview.events.SVEventType;
import com.google.scrollview.ui.SVWindow;
import org.piccolo2d.PCamera;
import org.piccolo2d.PNode;
import org.piccolo2d.event.PBasicInputEventHandler;
Reported by PMD.
Line: 44
* @author wanke@google.com
*/
public class SVEventHandler extends PBasicInputEventHandler implements
ActionListener, KeyListener, WindowListener {
/** Necessary to wait for a defined period of time (for SVET_HOVER). */
public Timer timer;
/** The window which the event corresponds to. */
Reported by PMD.
Line: 47
ActionListener, KeyListener, WindowListener {
/** Necessary to wait for a defined period of time (for SVET_HOVER). */
public Timer timer;
/** The window which the event corresponds to. */
private SVWindow svWindow;
/** These are used to determine a selection size (for SVET_SELECTION). */
Reported by PMD.
Line: 50
public Timer timer;
/** The window which the event corresponds to. */
private SVWindow svWindow;
/** These are used to determine a selection size (for SVET_SELECTION). */
private int lastX = 0;
private int lastY = 0;
Reported by PMD.
Line: 50
public Timer timer;
/** The window which the event corresponds to. */
private SVWindow svWindow;
/** These are used to determine a selection size (for SVET_SELECTION). */
private int lastX = 0;
private int lastY = 0;
Reported by PMD.
Line: 53
private SVWindow svWindow;
/** These are used to determine a selection size (for SVET_SELECTION). */
private int lastX = 0;
private int lastY = 0;
/**
* These are used in case we want to transmit our position, but do not get it
* because it was no MouseEvent, in particular SVET_HOVER and SVET_INPUT.
Reported by PMD.
Line: 53
private SVWindow svWindow;
/** These are used to determine a selection size (for SVET_SELECTION). */
private int lastX = 0;
private int lastY = 0;
/**
* These are used in case we want to transmit our position, but do not get it
* because it was no MouseEvent, in particular SVET_HOVER and SVET_INPUT.
Reported by PMD.
Line: 54
/** These are used to determine a selection size (for SVET_SELECTION). */
private int lastX = 0;
private int lastY = 0;
/**
* These are used in case we want to transmit our position, but do not get it
* because it was no MouseEvent, in particular SVET_HOVER and SVET_INPUT.
*/
Reported by PMD.
Line: 54
/** These are used to determine a selection size (for SVET_SELECTION). */
private int lastX = 0;
private int lastY = 0;
/**
* These are used in case we want to transmit our position, but do not get it
* because it was no MouseEvent, in particular SVET_HOVER and SVET_INPUT.
*/
Reported by PMD.
unittest/stringrenderer_test.cc
48 issues
Line: 82
std::unique_ptr<StringRenderer> renderer_;
};
TEST_F(StringRendererTest, DoesRenderToImage) {
renderer_ = std::make_unique<StringRenderer>("Verdana 10", 600, 600);
Image pix = nullptr;
EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix));
EXPECT_TRUE(pix != nullptr);
EXPECT_GT(renderer_->GetBoxes().size(), 0);
Reported by Cppcheck.
Line: 85
Column: 13
CWE codes:
126
TEST_F(StringRendererTest, DoesRenderToImage) {
renderer_ = std::make_unique<StringRenderer>("Verdana 10", 600, 600);
Image pix = nullptr;
EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix));
EXPECT_TRUE(pix != nullptr);
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
Reported by FlawFinder.
Line: 85
Column: 66
CWE codes:
126
TEST_F(StringRendererTest, DoesRenderToImage) {
renderer_ = std::make_unique<StringRenderer>("Verdana 10", 600, 600);
Image pix = nullptr;
EXPECT_EQ(strlen(kEngText), renderer_->RenderToImage(kEngText, strlen(kEngText), &pix));
EXPECT_TRUE(pix != nullptr);
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
Reported by FlawFinder.
Line: 92
Column: 13
CWE codes:
126
pix.destroy();
renderer_ = std::make_unique<StringRenderer>("UnBatang 10", 600, 600);
EXPECT_EQ(strlen(kKorText), renderer_->RenderToImage(kKorText, strlen(kKorText), &pix));
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
renderer_ = std::make_unique<StringRenderer>("Lohit Hindi 10", 600, 600);
Reported by FlawFinder.
Line: 92
Column: 66
CWE codes:
126
pix.destroy();
renderer_ = std::make_unique<StringRenderer>("UnBatang 10", 600, 600);
EXPECT_EQ(strlen(kKorText), renderer_->RenderToImage(kKorText, strlen(kKorText), &pix));
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
renderer_ = std::make_unique<StringRenderer>("Lohit Hindi 10", 600, 600);
Reported by FlawFinder.
Line: 98
Column: 13
CWE codes:
126
pix.destroy();
renderer_ = std::make_unique<StringRenderer>("Lohit Hindi 10", 600, 600);
EXPECT_EQ(strlen(kHinText), renderer_->RenderToImage(kHinText, strlen(kHinText), &pix));
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
// RTL text
Reported by FlawFinder.
Line: 98
Column: 66
CWE codes:
126
pix.destroy();
renderer_ = std::make_unique<StringRenderer>("Lohit Hindi 10", 600, 600);
EXPECT_EQ(strlen(kHinText), renderer_->RenderToImage(kHinText, strlen(kHinText), &pix));
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
// RTL text
Reported by FlawFinder.
Line: 105
Column: 13
CWE codes:
126
// RTL text
renderer_ = std::make_unique<StringRenderer>("Arab 10", 600, 600);
EXPECT_EQ(strlen(kArabicText), renderer_->RenderToImage(kArabicText, strlen(kArabicText), &pix));
EXPECT_TRUE(pix != nullptr);
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
Reported by FlawFinder.
Line: 105
Column: 72
CWE codes:
126
// RTL text
renderer_ = std::make_unique<StringRenderer>("Arab 10", 600, 600);
EXPECT_EQ(strlen(kArabicText), renderer_->RenderToImage(kArabicText, strlen(kArabicText), &pix));
EXPECT_TRUE(pix != nullptr);
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
Reported by FlawFinder.
Line: 113
Column: 70
CWE codes:
126
// Mixed direction Arabic + english text
renderer_ = std::make_unique<StringRenderer>("Arab 10", 600, 600);
EXPECT_EQ(strlen(kMixedText), renderer_->RenderToImage(kMixedText, strlen(kMixedText), &pix));
EXPECT_TRUE(pix != nullptr);
EXPECT_GT(renderer_->GetBoxes().size(), 0);
DisplayClusterBoxes(pix);
pix.destroy();
}
Reported by FlawFinder.
src/ccstruct/points.h
23 issues
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
Line: 195
/// constructor
///@param xvalue x value
///@param yvalue y value
FCOORD(float xvalue, float yvalue) {
xcoord = xvalue; // set coords
ycoord = yvalue;
}
FCOORD( // make from ICOORD
ICOORD icoord) { // coords to set
Reported by Cppcheck.
src/ccutil/scanutils.cpp
23 issues
Line: 67
Column: 22
CWE codes:
120
20
static inline int SkipSpace(FILE *s) {
int p;
while (isascii(p = fgetc(s)) && isspace(p)) {
;
}
ungetc(p, s); // Make sure next char is available for reading
return p;
}
Reported by FlawFinder.
Line: 132
Column: 60
CWE codes:
120
20
}
// Actual number parsing
for (; (c != EOF) && (d = DigitValue(c, base)) >= 0; c = fgetc(s)) {
v = v * base + d;
}
ungetc(c, s);
return minus ? -v : v;
Reported by FlawFinder.
java/com/google/scrollview/ui/SVMenuBar.java
20 issues
Line: 95
else {
SVAbstractMenuItem jmi = items.get(parent);
if (jmi == null) {
System.out.println("ERROR: Unknown parent " + parent);
System.exit(1);
}
SVAbstractMenuItem mli = new SVEmptyMenuItem(id, name);
mli.mi.addActionListener(this);
items.put(name, mli);
Reported by PMD.
Line: 121
public void add(String parent, String name, int id, boolean b) {
SVAbstractMenuItem jmi = items.get(parent);
if (jmi == null) {
System.out.println("ERROR: Unknown parent " + parent);
System.exit(1);
}
SVAbstractMenuItem mli = new SVCheckboxMenuItem(id, name, b);
mli.mi.addActionListener(this);
items.put(name, mli);
Reported by PMD.
Line: 14
package com.google.scrollview.ui;
import com.google.scrollview.events.SVEventType;
import com.google.scrollview.ui.SVWindow;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
Reported by PMD.
Line: 33
*/
public class SVMenuBar implements ActionListener {
/** The root entry to add items to. */
private JMenuBar root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
Reported by PMD.
Line: 33
*/
public class SVMenuBar implements ActionListener {
/** The root entry to add items to. */
private JMenuBar root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
Reported by PMD.
Line: 35
/** The root entry to add items to. */
private JMenuBar root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVMenuBar and place it at the top of the ScrollView window.
Reported by PMD.
Line: 35
/** The root entry to add items to. */
private JMenuBar root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVMenuBar and place it at the top of the ScrollView window.
Reported by PMD.
Line: 35
/** The root entry to add items to. */
private JMenuBar root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVMenuBar and place it at the top of the ScrollView window.
Reported by PMD.
Line: 37
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVMenuBar and place it at the top of the ScrollView window.
*
* @param scrollView The window our menubar belongs to.
Reported by PMD.
Line: 37
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVMenuBar and place it at the top of the ScrollView window.
*
* @param scrollView The window our menubar belongs to.
Reported by PMD.
src/ccutil/unicharset.cpp
19 issues
Line: 1045
Column: 3
CWE codes:
120
Suggestion:
Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused)
script_table = new_script_table;
}
script_table[script_table_size_used] = new char[strlen(script) + 1];
strcpy(script_table[script_table_size_used], script);
return script_table_size_used++;
}
// Returns the string that represents a fragment
// with the given unichar, pos and total.
Reported by FlawFinder.
Line: 305
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
int step = 1;
// Chop into unicodes and code each as hex.
for (int i = 0; str[i] != '\0'; i += step) {
char hex[sizeof(int) * 2 + 1];
step = UNICHAR::utf8_step(str + i);
if (step == 0) {
step = 1;
sprintf(hex, "%x", str[i]);
} else {
Reported by FlawFinder.
Line: 309
Column: 7
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
step = UNICHAR::utf8_step(str + i);
if (step == 0) {
step = 1;
sprintf(hex, "%x", str[i]);
} else {
UNICHAR ch(str + i, step);
sprintf(hex, "%x", ch.first_uni());
}
result += hex;
Reported by FlawFinder.
Line: 312
Column: 7
CWE codes:
120
Suggestion:
Use sprintf_s, snprintf, or vsnprintf
sprintf(hex, "%x", str[i]);
} else {
UNICHAR ch(str + i, step);
sprintf(hex, "%x", ch.first_uni());
}
result += hex;
result += " ";
}
result += "]";
Reported by FlawFinder.
Line: 697
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
bool UNICHARSET::save_to_string(std::string &str) const {
const int kFileBufSize = 1024;
char buffer[kFileBufSize + 1];
snprintf(buffer, kFileBufSize, "%d\n", this->size());
str = buffer;
for (UNICHAR_ID id = 0; id < this->size(); ++id) {
int min_bottom, max_bottom, min_top, max_top;
get_top_bottom(id, &min_bottom, &max_bottom, &min_top, &max_top);
Reported by FlawFinder.
Line: 758
Column: 3
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
bool UNICHARSET::load_via_fgets(std::function<char *(char *, int)> fgets_cb, bool skip_fragments) {
int unicharset_size;
char buffer[256];
this->clear();
if (fgets_cb(buffer, sizeof(buffer)) == nullptr || sscanf(buffer, "%d", &unicharset_size) != 1) {
return false;
}
Reported by FlawFinder.
Line: 765
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
return false;
}
for (UNICHAR_ID id = 0; id < unicharset_size; ++id) {
char unichar[256];
unsigned int properties;
char script[64];
strncpy(script, null_script, sizeof(script) - 1);
int min_bottom = 0;
Reported by FlawFinder.
Line: 767
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
for (UNICHAR_ID id = 0; id < unicharset_size; ++id) {
char unichar[256];
unsigned int properties;
char script[64];
strncpy(script, null_script, sizeof(script) - 1);
int min_bottom = 0;
int max_bottom = UINT8_MAX;
int min_top = 0;
Reported by FlawFinder.
Line: 788
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
if (fgets_cb(buffer, sizeof(buffer)) == nullptr) {
return false;
}
char normed[64];
normed[0] = '\0';
std::istringstream stream(buffer);
stream.imbue(std::locale::classic());
// 标 1 0,255,0,255,0,0,0,0,0,0 Han 68 0 68 标 # 标 [6807 ]x
// stream.flags(std::ios::hex);
Reported by FlawFinder.
Line: 1035
Column: 24
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
}
if (script_table_size_reserved == 0) {
script_table_size_reserved = 8;
script_table = new char *[script_table_size_reserved];
} else if (script_table_size_used >= script_table_size_reserved) {
assert(script_table_size_used == script_table_size_reserved);
script_table_size_reserved += script_table_size_reserved;
char **new_script_table = new char *[script_table_size_reserved];
memcpy(new_script_table, script_table, script_table_size_used * sizeof(char *));
Reported by FlawFinder.
java/com/google/scrollview/ui/SVPopupMenu.java
19 issues
Line: 86
else {
SVAbstractMenuItem jmi = items.get(parent);
if (jmi == null) {
System.out.println("ERROR: Unknown parent " + parent);
System.exit(1);
}
SVAbstractMenuItem mli = new SVEmptyMenuItem(id, name);
mli.mi.addActionListener(this);
items.put(name, mli);
Reported by PMD.
Line: 14
package com.google.scrollview.ui;
import com.google.scrollview.events.SVEventType;
import com.google.scrollview.ui.SVMenuItem;
import com.google.scrollview.ui.SVWindow;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Reported by PMD.
Line: 15
import com.google.scrollview.events.SVEventType;
import com.google.scrollview.ui.SVMenuItem;
import com.google.scrollview.ui.SVWindow;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
Reported by PMD.
Line: 36
public class SVPopupMenu implements ActionListener {
/** The root entry to add items to. */
private JPopupMenu root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
Reported by PMD.
Line: 36
public class SVPopupMenu implements ActionListener {
/** The root entry to add items to. */
private JPopupMenu root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
Reported by PMD.
Line: 38
/** The root entry to add items to. */
private JPopupMenu root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVPopupMenu and associate it with a ScrollView window.
Reported by PMD.
Line: 38
/** The root entry to add items to. */
private JPopupMenu root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVPopupMenu and associate it with a ScrollView window.
Reported by PMD.
Line: 38
/** The root entry to add items to. */
private JPopupMenu root;
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVPopupMenu and associate it with a ScrollView window.
Reported by PMD.
Line: 40
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVPopupMenu and associate it with a ScrollView window.
*
* @param sv The window our popup menu belongs to.
Reported by PMD.
Line: 40
/** Contains a map of item name to its actual entry. */
private HashMap<String, SVAbstractMenuItem> items;
/** The window the menubar belongs to. */
private SVWindow svWindow;
/**
* Create a new SVPopupMenu and associate it with a ScrollView window.
*
* @param sv The window our popup menu belongs to.
Reported by PMD.