Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite046e1d

Browse files
committed
The current implementation of BlobInputStream does
not properly handle 8-bit unsigned data as it blindlycasts the byte to an int, which java most helpfullypromotes to a signed type. This causes problems whenyou can only return -1 to indicated EOF.The following patch fixes the bug and has been testedlocally on image data.Chad David
1 parentdbb219b commite046e1d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

‎src/interfaces/jdbc/org/postgresql/largeobject/BlobInputStream.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,24 @@ public BlobInputStream(LargeObject lo,int bsize) {
5858
*/
5959
publicintread()throwsjava.io.IOException {
6060
try {
61-
if(buffer==null ||bpos>=buffer.length) {
61+
if(buffer ==null ||bpos >=buffer.length) {
6262
buffer=lo.read(bsize);
6363
bpos=0;
6464
}
6565

6666
// Handle EOF
67-
if(bpos>=buffer.length)
67+
if(bpos >=buffer.length) {
6868
return -1;
69+
}
70+
71+
intret = (buffer[bpos] &0x7F);
72+
if ((buffer[bpos] &0x80) ==0x80) {
73+
ret |=0x80;
74+
}
6975

70-
return (int)buffer[bpos++];
76+
bpos++;
77+
78+
returnret;
7179
}catch(SQLExceptionse) {
7280
thrownewIOException(se.toString());
7381
}
@@ -152,5 +160,4 @@ public synchronized void reset() throws IOException {
152160
publicbooleanmarkSupported() {
153161
returntrue;
154162
}
155-
156-
}
163+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp